onBeforeUnload handler says null in IE

前端 未结 2 1103
深忆病人
深忆病人 2021-01-01 20:34

my web-app has this:

$(window).bind(\'beforeunload\', function() {
    if(unSavedChanges == true)
    {
        return \'You have unsaved changes\';
    }
           


        
2条回答
  •  无人及你
    2021-01-01 20:41

    I use normal javascript for this and works fine

    function setConfirmUnload(on) {
         window.onbeforeunload = (on) ? unloadMessage : null;
    }
    
    function unloadMessage() {
         return 'Please stay on the page';
    }
    

提交回复
热议问题