How to disable beforeunload action when user is submitting a form?
Call unbind
using the beforeunload
event handler:
$('form#someForm').submit(function() { $(window).unbind('beforeunload');});
To prevent the form from being submitted, add the following line:
return false;
Use
$('form').submit(function () { window.onbeforeunload = null;});
Make sure you have this before you main submit function! (if any)
This is what we use:
On the document ready we call the beforeunload function.
$(document).ready(function(){ $(window).bind("beforeunload", function(){ return(false); });});
Before any submit or location.reload we unbind the variable.
$(window).unbind('beforeunload');formXXX.submit();$(window).unbind("beforeunload"); location.reload(true);