您的位置:首页 > Web前端 > JavaScript

【JavaScript】window对象_frames数组对象

2015-03-08 01:04 489 查看
window对象的frames属性是一个数组,它与window对象的parent、top等

对象属性,都是用于对HTML的帧标签(<frameset>或<iframe>)进行编程的

javascript对象。(利用parent.frames.来调用)

framedemo.html:
<html>
<head>
</head>
<frameset rows="20%,80%">
<frame name=top src="top.html">
<frame name=bottom src="bottom.html">
</frameset>
</html>


脚本代码最好不要编写在framedemo.html中,

而是写在frame各个区域的网页中。

top.html:
<input type=button value="刷新"
onclink="window.parent.frames[1].loaction.reload()">
<!--刷新的是frame name=bottom-->

<input type=button value="刷新2"
onclink="parent.frames.bottom.loaction.reload()">

<input type=button value="刷新3"
onclink="parent.frames['bottom'].loaction.reload()">

<input type=button value="刷新4"
onclink="parent.frames.item(1).loaction.reload()">

<input type=button value="刷新5"
onclink="parent.frames.item('bottom').loaction.reload()">

<input type=button value="刷新6"
onclink="parent.bottom.loaction.reload()">

<input type=button value="刷新7"
onclink="parent['bottom'].loaction.reload()">

<!--个人觉得摔性能2与6比较好记-->


2.top属性:

例子:

top.html:
<frameset rows="20%,*">
<frame name="a">
<frame name="x" src="bottom.html">
</frameset>

bottom.html:
<frameset cols="30%,*">
<frame name="b">
<frame name="c" src="bottom_right.html">
</frameset>

bottom_right.html:
<script language="javascript">
parent.parent.a.document.write("www.baidu.com");
</script>
____________________________________________________
<frameset rows="20%,*">
<frame name="a">
<frameset cols="30%,*">
<frame name="b">
<frame name="c" src="bottom_right.html">
</frameset>
</frameset>

bottom_right.html:

<script language="javascript">
parent.a.document.write("www.baidu.com");
</script>


转载请注明出处:http://blog.csdn.net/acmman/article/details/44126609
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: