87,924
社区成员
发帖
与我相关
我的任务
分享
<body>
<iframe src='b.html'/>
</body>
<body>
<script>
//some code here...
//请问怎么从这里获取a.html里的那个iframe元素.
</script>
</body>
<body>
<iframe src='other.html'/>
<iframe src='b.html'/>
<iframe src='test.htm'/>
<iframe src='other.html'/>
<iframe src='other.html'/>
</body>
<script type="text/javascript">
window.onload =function(){
var a = parent.document.getElementsByTagName("iframe");
for(var i=0;i<a.length;i++){
if(a[i].contentWindow==document.parentWindow){
alert(a[i].src);
}
}
}
</script>
<body>
<iframe src='other.html'/>
<iframe src='b.html'/>
<iframe src='b.html'/>
<iframe src='other.html'/>
<iframe src='other.html'/>
</body>