iframe如何刷新的三種實現方案

iframe如何刷新一直都被網友所關注,接下來爲大家詳細介紹下三種:用iframe的name屬性定位/id屬性定位/當iframe的src爲其它網站地址時,感興趣的朋友可以參考下哈

<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe> 


方案一: 
用iframe的name屬性定位 

 

代碼如下:


<input type="button" name="Button" value="Button" onclick="document.frames('ifrmname').location.reload()">或 
<input type="button" name="Button" value="Button" onclick="document.all.ifrmname.document.location.reload()"> 


方案二: 
用iframe的id屬性定位 

 

代碼如下:


<input type="button" name="Button" value="Button" onclick="ifrmid.window.location.reload()"> 


終極方案: 
當iframe的src爲其它網站地址(跨域操作時) 

 

代碼如下:


<input type="button" name="Button" value="Button" onclick="window.open(document.all.ifrmname.src,'ifrmname','')"> 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章