Search

与我们合作

我们专注:网站策划设计、网络多媒体传播、网站优化及网站营销、品牌策略与设计
主营业务:网站建设、移动端微信小程序开发、VI设计、网络运营、云产品·运维解决方案

有一个品牌项目想和我们谈谈吗?

您可以填写右边的表格,让我们了解您的项目需求,这是一个良好的开始,我们将会尽快与您取得联系。当然也欢迎您给我们写信或是打电话,让我们听到您的声音

您也可通过下列途径与我们取得联系:

地 址: 深圳.龙岗区大运软件小镇11栋3楼

电 话: 138 2888 4598 / 138 0880 9053

网 址: http://www.appvx.cn

快速提交您的需求 ↓

javascript实现刷新iframe的方法的总结

时间:2017-09-01 浏览:3685 编辑:SW 来源:互联网

javascript实现刷新iframe的方法的总结,现在假设存在下面这样一个iframe,则刷新该iframe的N种方法有:


<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中是一个链接列表,其中的链接指向另一个iframe,用于显示内容。现在当内容内容添加后,在链接列表中添加了一条记录,则需要刷新列表iframe。


在内容iframe的提交js中使用parent.location.reload()将父页面全部刷新,因为另一个iframe没有默认的url,只能通过列表选择,所以只显示了列表iframe的内容。


使用window.parent.frames["列表iframe名字"].location="列表url"即可进刷新列表iframe,而内容iframe在提交后自己的刷新将不受影响。


document.frames("refreshAlarm").location.reload(true);


document.frames("refreshAlarm").document.location.reload(true);


document.frames("refreshAlarm").document.location="http://www.phpernote.com/";


document.frames("refreshAlarm").src="http://www.phpernote.com/";


注意区别:document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是http://www.phpernote.com/页面中那个iframe标签,所以对src属性操作有用。

document.frames("refreshAlarm").document得到iframe里面的内容,也就是"http://www.phpernote.com/"中的内容。


javascript(js)自动刷新页面的实现方法总结:


间隔10秒刷新一次,在页面的head标签中加入下面的代码段:


<meta http-equiv="refresh"content="10;url=跳转的页面或者是需要刷新的页面URL地址">


定时刷新页面(间隔2秒刷新一下页面):


<script language="javascript">

setTimeout("location.href='url'",2000);//url是要刷新的页面URL地址

</script>


直接刷新页面事件:


<script language="javascript">

window.location.reload(true);

//如需刷新iframe,则只需把window替换为响应的iframe的name属性值或ID属性值

</script>


直接刷新页面事件:


<script language=''javascript''>

window.navigate("本页面url");

</script>


直接刷新页面事件:


function abc(){

window.location.href="/blog/window.location.href";

setTimeout("abc()",10000);

}


刷新框架页:


<script language="javascript">

top.leftFrm.location.reload();

parent.frmTop.location.reload();

</script>



本站文章均为深正网站建设摘自权威资料,书籍,或网络原创文章,如有版权纠纷或者违规问题,请即刻联系我们删除,我们欢迎您分享,引用和转载,但谢绝直接搬砖和抄袭!感谢...
GO 欣赏案例
查看经典案例
在线咨询
电话咨询
0755-36630177
返回顶部
在线咨询 获取报价 电话咨询
获取报价
您的称呼:

*

您的电话:

*

您的邮箱:

*

提交 重置
重要的事情,电话里聊

接通客服

不方便的时候线上咨询,在线等哦