比如:Iframe下有N个<li></li>
那么我在IE下是这么获取的:window.frames["ajaxFrame"].document.getElementsByTagName(node);
这在FF中是不可以的。
请问在FF中如何获取?在网上查了很多资料都不顶用。
谢谢。。
那么我在IE下是这么获取的:window.frames["ajaxFrame"].document.getElementsByTagName(node);
这在FF中是不可以的。
请问在FF中如何获取?在网上查了很多资料都不顶用。
谢谢。。
<!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=utf-8" />
<title>无标题文档 </title>
<style type="text/css">
mytag{
border:1px solid #cccccc;
width:100px;
height:20px;
}
</style>
</head>
<body>
<input type="text" id="text1" value="1"/>
<input type="text" id="text2" value="2"/>
<input type="text" id="text3" value="3"/>
<input type="text" id="text4" value="4"/>
<mytag>1 </mytag>
<mytag>2 </mytag>
<mytag>3 </mytag>
<mytag>4 </mytag>
JScript code
<script>
alert("INPUT Count:"+document.getElementsByTagName("INPUT").length);
alert("MyTag Count:"+document.getElementsByTagName("mytag").length);
</script>
</body>
</html> 注意表头写发
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function test(){
var lis = window.frames["ajaxFrame"].document.documentElement.getElementsByTagName('li');
alert(lis.length);
}</script>
</head>
<body><iframe name="ajaxFrame" src="B.html"></iframe>
<input type="button" value="test" onclick="test">
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<li>xxxxxxxxx</li>
<li>xxxxxxxxx</li>
<li>xxxxxxxxx</li>
<li>xxxxxxxxx</li>
</body>
</html>
Iframe访问父窗口里面的元素,javascript可以这么写:window.parent.$("divID").innerHTML = unescape(data);window.parent.gj = -1; //gj是父窗口的一个js变量javascript真伟大啊,竟然在Iframe里面可以访问父窗口的javascript变量。。