js刷新框架子页面的七种方法

JavaScript010

js刷新框架子页面的七种方法,第1张

下面以三个页面分别命名为l l l为例来具体说明如何做

其中l由上下两个页面组成 代码如下

<!DOCTYPE HTML PUBLIC //W C//DTD HTML Transitional//EN ><HTML><HEAD><TITLE>frameDemo </TITLE></HEAD><frameset rows= % % ><frame name=top src= l ><frame name=button src= l ></frameset></HTML>

现在假设l即上面的页面有一个button来实现对下面页面的刷新 可以用以下七种语句 哪个好用自己看着办了

语句 window parent frames[ ] location reload()

语句 window parent frames bottom location reload()

语句 window parent frames[ bottom ] location reload()

语句 windem( ) location reload()

语句 windem( bottom ) location reload()

语句 window parent bottom location reload()

语句 window parent[ bottom ] location reload()

解释一下

window指代的是当前页面 例如对于此例它指的是l页面

parent指的是当前页面的父页面 也就是包含它的框架页面 例如对于此例它指的是l

frames是window对象 是一个数组 代表着该框架内所有子页面

em是方法 返回数组里面的元素

如果子页面也是个框架页面 里面还是其它的子页面 那么上面的有些方法可能不行   l源代码 (页面上有七个按钮 功能都是刷新下面的框架页面)

<!DOCTYPE HTML PUBLIC //W C//DTD HTML Transitional//EN ><HTML><HEAD></HEAD><BODY><input type=button value= 刷新 onclick= window parent frames[ ] location reload() ><br><input type=button value= 刷新 onclick= window parent frames bottom location reload() ><br><input type=button value= 刷新 onclick= window parent frames[ bottom ] location reload() ><br><input type=button value= 刷新 onclick= windem( ) location reload() ><br><input type=button value= 刷新 onclick= windem( bottom ) location reload() ><br><input type=button value= 刷新 onclick= window parent bottom location reload() ><br><input type=button value= 刷新 onclick= window parent[ bottom ] location reload() ><br></BODY></HTML>

下面是l页面源代码 为了证明下方页面的确被刷新了 在装载完页面弹出一个对话框

lishixinzhi/Article/program/Java/Javascript/201311/25475

简单回答:自己看,不再赘述

用iframe、弹出子页面刷新父页面

iframe

parent.location.reload()

弹出子页面

window.opener.location.reload()

子窗口刷新父窗口

self.window.opener.locaction.reload()

刷新一open()方法打开的窗口

window.opener.location.href = window.opener.location.href

刷新以winodw.showModelDialog()方法打开的窗口

window.parent.dialogArguments.document.execCommand('Refresh')

Response.Write("<script>window.location.href = window.location.href</script>")

刷新本页Response.Write("<script>window.location.href=window.location.href</script>")

刷新父页和本页面:

Response.Write("<script>alert('提交成功!')window.location.href=window.location.hrefwindow.opener.location=window.opener.location</script>")

用iframe、弹出子页面刷新父页面iframe<script language=JavaScript>parent.location.reload()</script>弹出子页面<script language=JavaScript>window.opener.location.reload()</script>子窗口刷新父窗口<script language=JavaScript></script>在framset框架中A窗口调用B窗口的JS方法:一般方法调用: A窗口中:window.parent.frames["result"].dialog_waiting.open("正在查询数据")//锁屏效果说明:其中result是指B窗口所在fram的name属性,dialog_waiting.open("正在查询数据")为B窗口中的JS方法。 A窗口刷新B窗口:window.parent.frames["result"].location.reload()