刷新iframe的实现方案

关于如何刷新iframe这个问题一直都是用户们比较关注的,尤其是在深入了解HTML后好奇心更甚,那么今天就让小编介绍刷新iframe的实现方案,感兴趣的小伙伴一起看看吧。

复制代码

代码如下:

 


<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’,”)”>
以上就是刷新iframe的实现方案,文中介绍了用iframe的name属性定位/id属性定位/当iframe的src为其它网站地址时的方法,希望对你有所帮助。