如果要是后台程序处理,比如.net的话,可以把先前页面的状态数据存入session或viewstate里。若是单独用js的话,可以把先前的页面数据放入hidden控件,然后当关闭窗体时去判断当前控件的值是否与hidden控件的value的值是否相等?不等则提示!

解决方案 »

  1.   

    页面内容的所有改变都会导致onbeforeunload事件的发生,怎么回事?
      

  2.   

    Event InformationBubbles No 
    Cancels Yes 
    To invoke Close the current browser window. 
    Navigate to another location by entering a new address or selecting a Favorite. 
    Click the Back, Forward, Refresh, or Home button. 
    Click on an a that refers the browser to another Web page. 
    Invoke the a?A HREF="../methods/click.html">click method. 
    Invoke the document?A HREF="../methods/write.html">write method. 
    Invoke the document?A HREF="../methods/open_1.html">open method. 
    Invoke the document?A HREF="../methods/close_1.html">close method. 
    Invoke the window?A HREF="../methods/close_0.html">close method. 
    Invoke the window?A HREF="../methods/open_0.html">open method, providing the possible value _self for the window name. 
    Invoke the window?A HREF="../methods/navigate.html">navigate or NavigateAndFind method. 
    Invoke the location?A HREF="../methods/replace.html">replace method. 
    Invoke the location?A HREF="../methods/reload.html">reload method. 
    Specify a new value for the location?A HREF="../properties/href_3.html">href property. 
    Submit a form to the address specified in the action attribute via the input type=submit control, or invoke the form?A HREF="../methods/submit.html">submit method. 
     
    Default action Signals that the page is about to be unloaded.  
      

  3.   

    dawn06的回答已经接近我的问题的解决了。现在问题是:我的页面中肯定会有一些<a href="javascript:xxxxxx">
    我如何判断当前的onbeforeunload是由谁引发的。我发现,此时的event居然没有srcElement,那我如何剔出a标签引发的onbeforeunload呢?
      

  4.   

    现在,我是如下处理的:
    将所有A标签改为“<a href="#" onclick="xxxxx();">tttt</a>”
    是否另有好办法来剔除非真正卸载页面的事件?
      

  5.   

    在body中加载这些事件吧,unload="",unload事件中先检查表单数据有无改变,有改变,则提示