Check if changes saved before unload

后端 未结 2 1339
离开以前
离开以前 2021-01-22 10:41

I have the following JavaScript

EDIT: included assignments for changesSaved

 var changesSaved = true;

    $(document).ready(function ()         


        
2条回答
  •  悲哀的现实
    2021-01-22 10:58

    
    
    function bye(){
        if(changesSaved) {
            return "You havent saved your changes."
        }
    }
    

    This is how I do it.

    or in pure JavaScript:

    window.onbeforeunload = function() {
        if (changesSaved) {
            return "You haven't saved your changes.";
        }
    };
    

提交回复
热议问题