jConfirm and onbeforeunload
Posted
by Dirty Bird Design
on Stack Overflow
See other posts from Stack Overflow
or by Dirty Bird Design
Published on 2010-06-15T17:17:37Z
Indexed on
2010/06/15
17:22 UTC
Read the original article
Hit count: 340
jQuery
I have a basic function to alert the user upon refresh, browser back button (except the submit button) or when a link is clicked they will lose form data from a form wizard.
<script type="text/javascript">
var okToSubmit = false;
window.onbeforeunload = function() {
document.getElementById('Register').onclick = function() { okToSubmit = true; };
if(!okToSubmit) return "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form";
};
</script>
Im using jAlert plug in for alerts and would like to use jConfirm for the function above. When I add jConfirm after "return" it works...for a second. it pops the warning and then the page refreshes and the dialog box goes away. Does anyone know how to fix this?
© Stack Overflow or respective owner