如题,
比如
a.html 为
<body>
<iframe src='b.html'/>
</body>
b.html 为<body>
<script>
//some code here...
//请问怎么从这里获取a.html里的那个iframe元素.
</script>
</body>谢谢!
比如
a.html 为
<body>
<iframe src='b.html'/>
</body>
b.html 为<body>
<script>
//some code here...
//请问怎么从这里获取a.html里的那个iframe元素.
</script>
</body>谢谢!
<iframe id="b" src='b.html'/>
</body><body>
<script>
//some code here...
//请问怎么从这里获取a.html里的那个iframe元素.
var bIframe = parent.getElementById('b')
</script>
</body>
alert(top.document.getElementById("i1").clientHeight);
alert(top.document.getElementById("i1").clientWidth);
然后对每个数组元素的src属性进行判断,是b.html则咋咋咋
如下:<body>
<iframe src='other.html'/>
<iframe src='b.html'/>
<iframe src='b.html'/>
<iframe src='other.html'/>
<iframe src='other.html'/>
</body>请问怎么在b.html获取对应他自己的那个iframe元素?
然后对每个数组元素的contentWindow 属性进行判断,是self则咋咋咋
<body>
<iframe src='other.html'/>
<iframe src='b.html'/>
<iframe src='test.htm'/>
<iframe src='other.html'/>
<iframe src='other.html'/>
</body>
test.htm<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>