比如我打开3 个iframe src=1.html
1.html 有个button onclick 事件是到parent将自己的iframe removeNode
这个如何实现

解决方案 »

  1.   

    楼主这个是无法做到的,在1.html里的参数已经不再是开始页面里的元素了,只是视觉上是而已
      

  2.   

    补充一下吧,我做的是页面窗口,就是获取url后在这个页面生成iframe出这个URL页面然后提交页面后script关闭iframe其实方法应该有的,试了很多都无法实现
      

  3.   

    这个很容易实现呀,下面是你的iframe页面的代码:<HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
        <SCRIPT LANGUAGE="JavaScript">
      <!--
    function rmv() {
    alert(1);
    parent.document.body.removeChild(parent.document.getElementById('a'));
    }
      //-->
      </SCRIPT>
     </HEAD> <BODY>
     <INPUT TYPE="button" VALUE="remove" ONCLICK="rmv();">
     </BODY>
    </HTML>
      

  4.   

     2.html<html>
    <body>
    <iframe src="1.html"></iframe>
    <iframe src="1.html"></iframe>
    <iframe src="1.html"></iframe> 
    <A href="">asdf</A>
    </body>
    </html><script> 
    function box(d)
    {
    for(var i=0;i<frames.length;i++)
    {if(d==frames[i].document){alert(i);frames[i].frameElement.removeNode(1);}}

    </script>
    1.html<html>
    <body>
    <button onclick="top.box(document)">1</button>
    </body>
    <html>
    一个能答的都没有,自己实现
      

  5.   

    不错,不过楼主你的代码不是报错了吗?在ff下。在ie没有反应
      

  6.   

    LZ的代码IE没问题,FF有问题。原因是removeNode在FF下不支持。
    其实就是个top嘛,用parent在这情况下一样的,你甚至可以直接写window.box,思路对的就行。
      

  7.   

    window.top,到顶层对象,然后找到iframe,然后再remove
      

  8.   

    http://blog.csdn.net/flying8761/archive/2010/05/04/5554967.aspx