javascript - How to stop the page from redirecting to another page without the user action (StopPropogation)? -


function confirmexit(e) {  var f = formchanges();  //checking whether page has been modified or not      if (f.length > 0){     if (submitform == false) {         if(!e) var e = window.event;         //e.cancelbubble ie , work         e.cancelbubble = true;         e.returnvalue = "you have made updates page have not been saved.";         //e.stoppropagation firefox doesn't work.         if (e.stoppropagation) {             e.stoppropagation();             e.preventdefault();         }             }      }    settimeout("enablebeforeunloadhandler()", "100"); }  } //ignore   window.onbeforeunload=confirmexit;  function enablebeforeunloadhandler() {   window.onbeforeunload=confirmexit; } 

when user wants go other page without submitting form in current page,it prompts whether leave page or not? problem is, redirects other page in couple of seconds without waiting user action @ all,how fix this? (i doesn't work in firefox,in ie works fine)

could this:

window.onbeforeunload = function() {     return "are sure want navigate away?"; } 

you need return true (change page) or false (stay on page).


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -