https://www.jb51.net/article/65013.htm

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="//www.jb51.net/";
document.frames("refreshAlarm").src="//www.jb51.net/";

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

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>

js实现刷新iframe的方法汇总的更多相关文章

  1. JS实现刷新iframe的方法

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

  2. JS、jQuery 刷新 iframe 的方法

    1.JavaScript 刷新 iframe 可以使用以下方法: document.getElementById('some_frame_id').contentWindow.location.rel ...

  3. html-javascript前端页面刷新重载的方法汇总

    记得我在兴安得力实习要转正的时候,我领导象征性的给我出了一套测试题目,里面就有js闭包和页面刷新等题目.今天把很久之前的测试题目之一,js页面刷新的方法以及页面自动刷新跳转和返回上一页和下一页等方法总 ...

  4. 原生JS替代jQuery的各种方法汇总

    前端发展很快,现代浏览器原生 API 已经足够好用.我们并不需要为了操作 DOM.Event 等再学习一下 jQuery 的 API.同时由于 React.Angular.Vue 等框架的流行,直接操 ...

  5. JS 中刷新页面的方法

    整理了就是这几种,,有些在IE下面是不支持的,慎用... 1,history.go(0) 2,location.reload() 3,location=location 4,location.assi ...

  6. js禁止刷新的简单方法

    //禁止用F5键  这个是键盘按下时触发document.onkeydown = function() { if ( event.keyCode==116) {event.keyCode = 0; e ...

  7. 【转】js/jquery中刷新iframe方法(兼容主流)

    一.js实现刷新两种方式: 1.//方法1 2.document.getElementById('FrameID').contentWindow.location.reload(true); 3.// ...

  8. 前端Js跨域方法汇总—剪不断,理还乱,是跨域

    1.通过jsonp跨域2.通过修改document.domain来跨子域(iframe)3.隐藏的iframe+window.name跨域4.iframe+跨文档消息传递(XDM)5.跨域资源共享 C ...

  9. js返回上一页并刷新的多种方法

    js返回上一页并刷新的几种方法.参考链接:http://www.jbxue.com/article/11230.html <a href="javascript:history.go( ...

随机推荐

  1. Rpgmakermv(12) gacha插件系列

    很有趣的插件,可以做扭蛋啦,抽奖啦之类的东西.... 简单的示范: a.开始抽奖画面: b.抽奖中 c.随机得到物品 d.查看收集图鉴 e.图鉴内容 1.gacha 作用: get the item ...

  2. linux本地机上传文件到服务器

    最近工作全部切换到了linux环境下,就是吃喝拉撒全在linux下,微信,web端,qq,web端,-------,各种socket编程,网络通讯- 本地linux机从阿里云下载文件

  3. C#-----创建DataTable对象

    //DataTable表示内存中数据的一个表 DataTable dt = new DataTable(); /** * public DataColumn Add(string columnName ...

  4. rabbitmq和redis用作消息队列的区别

    将redis发布订阅模式用做消息队列和rabbitmq的区别: 可靠性redis :没有相应的机制保证消息的可靠消费,如果发布者发布一条消息,而没有对应的订阅者的话,这条消息将丢失,不会存在内存中:r ...

  5. mysql+servlet+jsp实现数据库的增删改查

    首先,了解数据库目前我们仅仅用来存放数据,在这里我们在数据库中生成一个表,包含id,classname,teacher,location.Tomcat用来配置eclipse,只有这样我们才能使用JSP ...

  6. 抓取https网页时,报错sun.security.validator.ValidatorException: PKIX path building failed 解决办法

    抓取https网页时,报错sun.security.validator.ValidatorException: PKIX path building failed 解决办法 原因是https证书问题, ...

  7. 系统调用号、errno

    最近老需要看系统调用号,errno,所以这里记一下 CentOS Linux release 7.2.1511 (Core) 3.10.0-327.el7.x86_64 [root@localhost ...

  8. FAQ About WOYO PDR007 Dent Removal Heat Induction System

    WOYO PDR 007 is a dent repair tool for auto maintence. WOYO PDR007 Auto Body Paintless Dent Repair K ...

  9. python 之xml.etree.ElementTree

    Element类型是一种灵活的容器对象,用于在内存中存储结构化数据. [注意]xml.etree.ElementTree模块在应对恶意结构数据时显得并不安全. 每个element对象都具有以下属性: ...

  10. javaweb项目中errorPage的问题

    我们的请求找不到时,会跳到错误页面,tomcat提供了一个错误页面,但是不太好.分析:tomcat自带错误页面不好的原因:有一下两点: 1.不好看: 2.不能为seo做出贡献.思考:如何解决以上问题? ...