当我从浏览器关闭此页面时,会打开一个警告框,询问“离开此页面”或“留在此页面”,没关系。但是当从下面给出的提交按钮提交表单时再次询问并显示这个警告框。我如何在提交表单时禁用它,它不应该被询问并显示警告框??
<script>
window.onbeforeunload = function(e) {
return 'You application form is not submitted yet.';
};
WinPrint.document.write('<span style="font-size:22px">' + prtContent.innerHTML + '<span>');
</script>
<div>
<input type="submit" name="" class="button" value="Save Your Application Form" onclick="if(document.getElementById('thumb').value=='') { alert('Please select your photograph.'); return false; } return confirm('Read your application form thoroughly before submitting, Once submitted data, it will not changed in any case, press OK to submit or press CANCEL to make corrections.'); return false;" style="text-align:center !important; float:none !important;"/>
</div>
最佳答案
$(document).on("submit", "form", function(event){
window.onbeforeunload = null;
});
应该做的事
关于javascript - 提交表单时如何禁用 "window.onbeforeunload"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26838894/