iframe都是自动生成的,没办法给每个iframe指定专有的名称。如何列举出所有的iframe对象,并可以使用其中的变量。
解决方案 »
- MapABC地图问题
- EXTJS中如何给选项卡内创建grid万分感激!
- javascript 解析顺序问题
- 一个js文件中的方法调用另一个js文件中的另一个方法,FF下错误 is not defined
- 请问为什么我在html中用js可以new ActiveXObject("WScript.Shell"),但是在jsp中却不行呢?小弟菜鸟,望各位帮助
- 关于用window.history.go后退次数好像只有6次?
- 如何得到下拉列表选框的文本值
- 请各位大侠帮忙看看这段JavaScript具体哪里出错了!
- 求救,单选框和下拉框的问题!!!!~~~~~~~~~~~~
- javascript如何改变div的底色和背影图片?
- jquery如何匹配只含文本的节点
- 我要左边的这个最新版的树状菜单源代码
for (i=0; i < frm.length; i++) alert(frm[i].xxxx);
var frm = block.getElementsByTagName(iframe);
for (i=0; i < frm.length; i++) alert(frm[i].contentWindow.xxxx);
就是要多建立俩个iframe,通过另外一个iframe来访问你的iframe
下面是例子
主页面代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>主页面 </title>
<script language="javascript">
</script>
</head>
<iframe id="baidu" src="http://baidu.com" name="baidu" > </iframe>
<iframe id="google" src="getDocument2.html" name="google" > </iframe>
<iframe id="getD" src="getDocument.html" name="getD"> </iframe>
<body>
</body>
</html>
getDocument2.html:
<html>
<head>
<script>
window.onload = function (){
alert(3);
alert(parent.document.frames.length);
alert(parent.document.frames["getD"].window.document.getElementById('up'));
alert(parent.document.frames["getD"].window.document.getElementById('up').innerHTML);
}
function getdocument(){
alert(4);
alert(parent.document.frames["getD"].window.document.getElementById('up').innerHTML);
}
</script>
</head>
<body>
<p id='up'>getDocument2 </p>
<p id='element'>getElement2 </p>
<input type="button" onclick="getdocument();" value="获取iframe"/>
</body>
</html>
getDocument.html:
<html>
<head>
</head>
<body>
<p id='up'>getDocument </p>
<p id='element'>getElement </p>
</body>
</html>
自己运行就可以了
一会儿结帖,要是上不了网就明天结。
帮忙看下这个:http://topic.csdn.net/u/20090718/15/b8ff6bd9-1f60-43bb-bf31-366282fd8f3b.html?seed=1816260280&r=58530188#r_58530188