How to remove prompt on unload event using javascript

前端 未结 2 1542
一生所求
一生所求 2021-01-15 14:44

How can I remove prompt on unload event using javascript? thanks in advance...

hm, I don\'t want to show the prompt when firing the custom function for the unlaod ev

2条回答
  •  醉酒成梦
    2021-01-15 15:13

    Most certainly NOT impossible. All you have to do to suppress the prompt is omit the "return" statement. Returning any value will cause the prompt to fire. Example:

               window.onbeforeunload = function saveAllData()
                {
                    //Invoke AJAX method to save DataTable in database
                    [classname].SaveDataTable();
                    //return true;                      //comment out 'return' to suppress prompt
                }
    
                function SaveDataTable_Callback(response) 
                {
                    //alert(response);
                }
    

提交回复
热议问题