How Can I Prevent A Page Unload With Jquery?
In my program, if a user tries to leave a page, he'll receive a dialog box asking if he is sure he wants to leave. How should I implement the 'cancel' option if the user chooses no
Solution 1:
window.onbeforeunload = function() {
return'You have unsaved changes!';
}
many question about this in stackoverflow How can I override the OnBeforeUnload dialog and replace it with my own?
Solution 2:
jQuery(window).on('beforeunload',function(){
var value = navigateAway(isDirty);
if(value=="changed")`enter code here`
{
if(jQuery("#saveCheck").val()=="false")
{
return "<?phpecho JText::_('OVR_WANT_TO_LEAVE');?>";
}
}
});
Post a Comment for "How Can I Prevent A Page Unload With Jquery?"