JavaScript use Alert Dialog Prevent Page Refresh and Page Close Mis-Operate

In Weh Dev, Sometime we need Prevent Mis-Operate from Page Refresh and Page Close, JavaScript will help a lot here, just add the follow code to Ready

window.onbeforeunload = function(event){    
    return 'Your Changes May not Save!!!'; 
};

 

{ PS }

When Click "Agree Leave"  and use same browser window go back again, the JavaScript Code will have no effect (the browser will auto use Agree Leave as default), so aways open a new window for new changes.