window.onbeforeunload = remove;function remove()
{
  KfUtil.test();//此处dwr调用后台代码,没有执行
}被充说明: 
  window.onunload = remove;也不行。 我想是因为还没有执行到页面就关了吧,估计是这样。 
请大家看看是什么原因,该怎么解决啊..

解决方案 »

  1.   

    不是吧LZ看我这个,多看看开发用的APIW文档哦没有我传给你  如下
    ExampleThis example uses the onbeforeunload event to ask users whether they want to remain on the current page or navigate to a new URL. When the user clicks on the hyperlink or attempts to close the browser window, the onbeforeunload event fires on the body and a dialog box appears. If the user chooses 'OK', the page navigates to the new URL (www.microsoft.com) or closes the window; if the user chooses 'Cancel', the page remains the same.HideExample<HTML>
    <HEAD>
    <SCRIPT>
    function closeIt()
    {
    event.returnValue = "Any string value here forces a dialog box to \
    appear before closing the window.";
    //window.onbeforeunload="closeIt()";
    }
    </SCRIPT>
    </HEAD>
    <BODY onbeforeunload="closeIt()">
    <a href="http://www.microsoft.com">Click here to navigate to
    www.microsoft.com</a>
    </BODY>
    </HTML>
      

  2.   

    好像我没有说明白,我要在页面关闭前用dwr调用后台代码,楼上的不行...
      

  3.   

     还有一个可能是DWR异步和同步的问题
    看看这骗文章
    http://liaijun82-live-cn.javaeye.com/blog/342978
      

  4.   

    remove函数执行了没有,先alert看看呢
    function remove()
    {
    alert("remove...");
      KfUtil.test();//此处dwr调用后台代码,没有执行
    }
      

  5.   

    alert("remove..."); 
    此处执行了。
    KfUtil.test();
    没有执行。。
      

  6.   

    在你的上个帖子里回过, 把alert放到remove函数的最后面试试看
      

  7.   

    可能 onbeforeunload 本来用意就不是给你在页面卸载前"干点什么"的, 用得比较多的地方是在函数里 return 一个消息, 这样在页面前可以提示一个消息, 并且询问你是不是确实要离开页面. 不用alert, 你可以试试这种方式.
      

  8.   

    onbeforeunload 不适合做异步执行,浏览器一般不等你的异步操作执行完就关闭了,并且异步操作会被中止 考虑用其他方法解决吧