注册 登录
编程论坛 JavaScript论坛

[求助]IE和FF中一个罕见的frames问题!求高手解答!!

皓月之空 发布于 2011-09-15 08:55, 414 次点击
我做了两个网页a.html(里面有上下框架),b.html(位于上面的框架中,里面有“测试”和“显示网页”按钮)。
我在IE和FireFox中,打开a.html后点击b.html中的“测试”按钮,可以正常显示。但是点击了“显示网页”按钮后再点“测试”按钮,IE就出错了,FF无反应!
不知道为什么?两个网页内容如下:

a.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<frameset rows="20%,*" frameborder="no" border="0" framespacing="0">
<frame src="b.html" name="tt" id="tt" title="tt" scrolling="No" noresize="noresize" />
<frame src="about:blank" name="rr" id="rr" title="rr" scrolling="No" noresize="noresize" />
</frameset>
</html>


b.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testA</title>
<script>
function go()
{
window.parent.frames[1].location = "http://www.baidu.com";
}
function test()
{
window.alert( window.parent.frames[1].document.documentElement.childNodes.length );
}
</script>
</head>
<body>
<input name="btnTEST" type="button" value="测试" onclick="test()"/>
<input name="btnGO" type="button" value="显示网页" onclick="go()"/>
</body>
</html>
2 回复
#2
刘杰明2011-09-19 14:19
window.alert( window.parent.frames[1].document.documentElement.childNodes.length );
这个你可以用循环试一下,frames[i]会比frames[1]好用
#3
aspic2011-09-24 15:38
跨域了 没有权限
1