javascript - Exclude submit button from beforeunload event -


i'm detecting form changes in page, , i've handled

$('#element').change(function(){ metadatachange = true; }); 

so when user leaves page , change made in input in form. he/she alerted whether leave or stay on page, in facebook try post status , leave page, dialog box prompted giving options either leave or stay in page.

$(window).on('beforeunload', function() {      if(metadatachange === true || basicinfochange === true){         return "you have unsaved changes, want leave without saving?";            } }); 

the code above works however.. want exclude submit button this. because when click "submit" , behavior of submit button means redirecting page. user prompted again same message when in fact he/she intends save his/her changes.

how exclude submit button being caught in beforeunload event of window? can hardly explain this... hope can understood..thanks!

$('#submitbutton').click(function(){ metadatachange = false; ...redirecting  }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -