本帖最后由 guanjie20 于 2011-03-11 12:08:00 编辑

解决方案 »

  1.   

    <html>
    <title>test</title>
    <head>
    <script type="text/javascript">
    window.onbeforeunload=function(){
       if(window.confirm('确定离开吗?'))
        { window.frames['ifrm'].document.getElementById('ifm').submit();}
       }</script>
    </head>
    <body>
      <a href="http://www.baidu.com">百度</a>
      <iframe style="display: none" src="iframe.html" name="ifrm"></iframe>
    </body>
    </html>改成这样试试!
      

  2.   


    js在主页面是正常的,但是我把js放在iframe上为什么就无效果了,真奇怪,我想把这段执行的js也放在iframe里
      

  3.   

    为什么这样不行:
    iframe.html:
    <html>
    <body onbeforeunload="window.frames['ifrm'].document.getElementById('ifm').submit();">
      <form id="ifm" name="ifm" method="get" action="http://test/fuc/">
      </form>
    </body>
    </html>
      

  4.   

    onbeforeunload="setTimeout(document.getElementById('ifm').submit(),1000);"或 onbeforeunload="setTimeout(window.frames['ifrm'].document.getElementById('ifm').submit(),1000);" 延迟1秒  没任何反应,