i have a form on my page and the submit button calls this function:I also have on the page an alert if the user tries to navigate away this alert is brought up:Code:function confirmSubmit() { var agree=confirm("Are you sure your report is complete?"); if (agree) return true ; else return false ; }The problem that has been brought to my attention is, if the user is submitting the form, both alert come up.Code:function goodbye(e) { if(!e) e = window.event; //e.cancelBubble is supported by IE - this will kill the bubbling process. e.cancelBubble = true; e.returnValue = '***YOU HAVE NOT SAVED YOUR REPORT***'; //This is displayed on the dialog //e.stopPropagation works in Firefox. if (e.stopPropagation) { e.stopPropagation(); e.preventDefault(); } } window.onbeforeunload=goodbye;
I would like to cancel out the 'function goodbye(e)' IF the user is hitting the submit button on the form and only have the first alert pop up.
Any help is much appreciated!



Reply With Quote
Bookmarks