关于frameset中遇到的奇怪问题
小弟,最近编了一个frameset网页,其中主页(frameSet.html)代码为:
<html>
<frameset rows="100,*">
<frame src="a.html" name="topFrame"></frame>
<frameset cols="200,*">
<frame src="b.html" name="leftFrame"></frame>
<frame src="c.html" name="rightFrame"></frame>
</frameset>
</frameset>
</html>
其中a.html:
<script>
function add(){
alert(parent.frames[0].name);
top.frames[1].document.getElementsByTagName("input")[0].value = self.document.getElementsByTagName("input")[0].value;
}
function open1(){
alert(parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent==top);
alert(parent.parent.parent.parent.parent.parent.frames[0].name);
alert(parent.frames[1].name);
alert(parent.frames[2].name);
window.open("b.html","topFrame");
}
</script>
<input type="text" name="atext">
<input type="button" value="aClick" onclick="add()">
<input type="button" value="window1" onclick="open1()">
b.html的代码:
<script>
function add(){
alert(parent==top);
alert(parent.frames[0].name);
alert(parent.frames[1].name);
alert(parent.frames[3].name);
top.frames[0].document.getElementsByTagName("input")[0].value = self.document.getElementsByTagName("input")[0].value;
}
</script>
<input type="text" name="btext">
<input type="button" value="bClick" onclick="add()">
c.html的代码为:
<script>
function add(){
alert(top.frames[1].name);
top.getElementsByTagName("input")[0].value = self.document.getElementsByTagName("input")[0].value;
}
</script>
<input type="text" name="ctext">
<input type="button" value="cClick" onclick="add()">
请大家注意那个b.html中我用parent=top来判断b.html的上一层是不是顶层,结果显示为true;因为我原先的框架有2层,结果parent.frames[0],parent.frames[1],parent.frames[2]竟然是a.html,b.html,c.html
我想要的结果是a.html的parent为顶层(top),b.html和c.html的parent.parent为顶层(top),(根据javascript权威指南第四版 252-253页)
哪位高手解释一下啊,我在IE和firefox中得到结果都一样啊