在父页面里点击一个链接,弹出一个子页面,子页面是一个框架,关闭子页面时刷新父页面,怎么办?

解决方案 »

  1.   

    父页面a.html 
    子页面b.html是一个框架,由c.html和d.html构成
    代码能给详细点吗?代码该放在哪个页面中?
      

  2.   

    子页面:
    <script>
    window.onbeforeunload=function(){
      opener.location.reload();
    }
    </script>
      

  3.   

    b.html:<frameset>
      <frame src="c.html">
      <frame src="d.html">
    </frameset><script>
    window.onunload = function() { opener.location.reload(); }
    </script>
      

  4.   

    opener.location.reload(); 
    报错“opener.location为空或不是对象”
      

  5.   

    如果子页面是用open弹出的,就用opener
    否则如果是showDialog/showModalDialog的话,就改成parent
      

  6.   

    把问题简单化:
    a.html:<a href='b.html' target='_blank'>打开新窗口</a>
    <input type=text value=''>
    b.html:<html>
    <head>
    <script>
    window.onbeforeunload=function(){
      opener.location.reload();
    }
    </script>
    </head>
    <frameset rows="50%,50%">
      <frame src="c.html">
      <frame src="d.html">
    </frameset>
    </html>如果你那里还报错,检查有没有冲突的地方
      

  7.   

    parnet.window.location.reload();
    框架top.opener.location.reload()
      

  8.   

    嗯 ,我是用showModalDialog弹出的 ,
    改成 parent.location.reload() 后虽然不报错了,但是却没有看到刷新效果......
      

  9.   

    说错了,showModalDialog这种方法弹出对话框,用parent没用,对子页面来说,parent就等于自己,也就是等于window/this正常做法是在父页面进行处理,比如:function foo() {
       var result = showModalDialog(...); //打开子页面,此时函数挂起,等待子页面关闭
       location.reload(); //到这句时,子页面已经关闭,在这里刷新是正确的做法
    }