JS实现刷新iframe的方法
2013-02-20 11:20
549 查看
对于如下一个 iframe,用 js 有什么么方法可以刷新它呢:
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>
方法一、location.reload()
根据定位 iframe 的方式不同,有以下方法:
1. 用iframe的name属性定位
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">
或
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">
2. 用iframe的id属性定位
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.window.location.reload()">
方法二、window.open()
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="window.open(document.all.ifrmname.src,'ifrmname','')">
该方法尤其适用于 iframe 的 src 为其它网站地址,即跨域操作的情况。
方法三、给 src 属性重新赋值
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.src=ifrmid.src">
<script type="text/javascript">
function partRefresh() {
document.getElementById("iframe1Id").src="2.html"; // 方法一: 通过和替换iframe的src来实现局部刷新
}
</script>
方法四、给 href 属性重新赋值
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.location.href=ifrmid.src">
转自:http://soli.iteye.com/blog/1754595
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>
方法一、location.reload()
根据定位 iframe 的方式不同,有以下方法:
1. 用iframe的name属性定位
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">
或
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">
2. 用iframe的id属性定位
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.window.location.reload()">
方法二、window.open()
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="window.open(document.all.ifrmname.src,'ifrmname','')">
该方法尤其适用于 iframe 的 src 为其它网站地址,即跨域操作的情况。
方法三、给 src 属性重新赋值
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.src=ifrmid.src">
<script type="text/javascript">
function partRefresh() {
document.getElementById("iframe1Id").src="2.html"; // 方法一: 通过和替换iframe的src来实现局部刷新
}
</script>
方法四、给 href 属性重新赋值
Html代码
![](http://soli.iteye.com/images/icon_star.png)
<input type="button" name="Button" value="Button"
onclick="ifrmid.location.href=ifrmid.src">
转自:http://soli.iteye.com/blog/1754595
相关文章推荐
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- 转:JS实现刷新iframe的方法
- js 能实现监听F5页面刷新子iframe 而父页面不刷新的方法
- JS实现刷新iframe的方法
- js实现刷新iframe的方法汇总
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- js实现刷新iframe的方法汇总
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- JS实现刷新iframe的方法
- 2011-03-17 18:49 JS实现刷新iframe的方法
- 【转】 JS实现刷新iframe的方法
- JS实现刷新iframe的方法