<frameset rows="107,*">
<frame src="1.html" name="frametop" />
<frameset name="ChangeRow" rows="*" cols="180,*">
<frame src="2.html" name="frame1" />
<frame src="3.html" name="frame2" />
</frameset>
</frameset>如何用js选择frame1和frame2??
如果是IE的话,我知道可以这样:window.parent.frames[1]//选中frame1;
window.parent.frames[2]//选中frame2;
但在chrome中却会报错!
求解chrome中该如何选中???
document.getElementsByTagName('frame')[2]
parent.frames["frame2"]
chrome下 可以的
像下面的代码依然不能在chrome中执行,ie里就可以。没懂为啥<p>First Frame</p>
<script type="text/javascript">
function display(){
parent.frames["frame1"].document.getElementById('b').style.backgroundColor='red';
}
</script>
<input type="button" value="button" onclick="display()" />
contentDocument
Uncaught TypeError:Cannot call method'getelementById' of undefined
文件名:testFrame.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title></head>
<frameset rows="107,*">
<frame src="1.html" name="frametop" />
<frameset name="ChangeRow" rows="*" cols="180,*">
<frame src="2.html" name="frame1" />
<frame src="3.html" name="frame2" />
</frameset>
</frameset>
<body>
<script type="text/javascript"></script>
</body>
</html>
文件名:1.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="a">
<p>First Frame</p>
<script type="text/javascript">
function display(){
parent.frames["frame1"].document.getElementById('b').style.backgroundColor='red';
}
</script>
<input type="button" value="button" onclick="display()" />
</div>
</body>
</html>文件名:2.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="b">
<p>Second Frame</p>
</div>
</body>
</html>文件名:3.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="c">
<p>Third</p>
</div>
</body>
</html>
chrome上传到服务器上就好了