<script>
window.attachEvent('onunload',function(){alert('尊敬的客户,为了方便核对机票或酒店信息建议您收藏本页!');window.external.addFavorite('http://www.','上海');});
</script>

解决方案 »

  1.   

    'onunload'并不是关闭窗口事件,而是页面卸载事件,只要当前页面退出就会触发该事件.
      

  2.   


    window.attachEvent('onunload', function(){
    if (confirm('尊敬的客户,为了方便核对机票或酒店信息建议您收藏本页!')) {
    window.external.addFavorite('http://www.163.com', '上海');
    }
    });
      

  3.   

    onunloadTo 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 anchor that refers the browser to another Web page. 
    Invoke the anchor?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 submit method 
      

  4.   

    onunload 事件在用户退出页面时发生。 
    当你连接在其他页面时选择在新窗口打开,就不会触发该事件了。