如题,
比如
a.html 为
<body>
  <iframe src='b.html'/>
</body>
b.html 为<body>
<script>
 //some code here...
 //请问怎么从这里获取a.html里的那个iframe元素.
</script>
</body>谢谢!

解决方案 »

  1.   

    <body>
      <iframe id="b" src='b.html'/>
    </body><body>
    <script>
     //some code here...
     //请问怎么从这里获取a.html里的那个iframe元素.
     var bIframe = parent.getElementById('b')
    </script>
    </body>
      

  2.   

    假如没有id 也没有name,而且也有可能有多个iframe呢?
      

  3.   

    a.html<iframe id="i1" src="iframe.htm"></iframe>b.html
    alert(top.document.getElementById("i1").clientHeight);
    alert(top.document.getElementById("i1").clientWidth);
      

  4.   

    getElementsByTagName("iframe")
    然后对每个数组元素的src属性进行判断,是b.html则咋咋咋
      

  5.   

    我不能修改a.html,我只能修改b.html。而且a.html中有多个iframe, 每个iframe都没有id和name. 而且我的b.html也有多个iframe引用,
    如下:<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元素?
      

  6.   

    getElementsByTagName("iframe")
    然后对每个数组元素的contentWindow 属性进行判断,是self则咋咋咋
      

  7.   


    <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>
      

  8.   

    建议用用ie8,chrome的开发人员工具或者firebug,一展开所有属性方法全看到