当前位置:首页 > 设计在线 > 平面动画 > Photoshop > 用Javascript刷新框架子页面的七种方法

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

点击次数:25 次 发布日期:2008-11-21 11:37:30 作者:源代码网
源代码网推荐

源代码网整理以下下面以三个页面分别命名为framedemo.html,top.html,button.html为例来具体说明如何做。

源代码网整理以下其中framedemo.html由上下两个页面组成,代码如下:

源代码网整理以下

以下为引用的内容:

源代码网整理以下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> frameDemo </TITLE>
</HEAD>
<frameset rows="50%,50%">
<frame name=top src="top.html">
<frame name=button src="button.html">
</frameset>
</HTML>

源代码网整理以下 现在假设top.html即上面的页面有一个button来实现对下面页面的刷新,可以用以下七种语句,哪个好用自己看着办了。

源代码网整理以下语句1. window.parent.frames[1].location.reload();

源代码网整理以下语句2. window.parent.frames.bottom.location.reload();

源代码网整理以下语句3. window.parent.frames["bottom"].location.reload();

源代码网整理以下语句4. window.parent.frames.item(1).location.reload();

源代码网整理以下语句5. window.parent.frames.item("bottom").location.reload();

源代码网整理以下语句6. window.parent.bottom.location.reload();

源代码网整理以下语句7. window.parent["bottom"].location.reload();

源代码网整理以下解释一下:

源代码网整理以下1.window指代的是当前页面,例如对于此例它指的是top.html页面。

源代码网整理以下2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是framedemo.html。

源代码网整理以下3.frames是window对象,是一个数组。代表着该框架内所有子页面。

源代码网整理以下4.item是方法。返回数组里面的元素。

源代码网整理以下5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。

源代码网整理以下top.html源代码;(页面上有七个按钮,功能都是刷新下面的框架页面)

源代码网整理以下

以下为引用的内容:

源代码网整理以下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY>
<input type=button value="刷新1" onclick="window.parent.frames[1].location.reload()"><br>
<input type=button value="刷新2" onclick="window.parent.frames.bottom.location.reload()"><br>
<input type=button value="刷新3" onclick="window.parent.frames["bottom"].location.reload()"><br>
<input type=button value="刷新4" onclick="window.parent.frames.item(1).location.reload()"><br>
<input type=button value="刷新5" onclick="window.parent.frames.item("bottom").location.reload()"><br>
<input type=button value="刷新6" onclick="window.parent.bottom.location.reload()"><br>
<input type=button value="刷新7" onclick="window.parent["bottom"].location.reload()"><br>
</BODY>
</HTML>

源代码网整理以下下面是bottom.html页面源代码,为了证明下方页面的确被刷新了,在装载完页面弹出一个对话框。

源代码网整理以下

以下为引用的内容:

源代码网整理以下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY onload="alert("我被加载了!")">
<h1>This is the content in button.html.</h1>
</BODY>
</HTML>

源代码网供稿.
网友评论 (0)
会员中心
设计在线
本站推荐
设计在线之精华