[ACCEPTED]-Firefox 4 onBeforeUnload custom message-firefox4
From MDN:
Note that in Firefox 4 and later the 8 returned string is not displayed to the 7 user. See Bug 588292.
This "Bug" is actually 6 a (imho questionable) feature.. so there's 5 no way to display the message in Firefox 4 4. If you think it should be changed, comment 3 on that bug so the Firefox developers will 2 know that people actually want to be able 1 to show a custom string.
Addition to the above Answer, I have improved 2 the workaround.
I have used jquery here. you 1 can use default javascript funciton as well.
$(window).bind('beforeunload', function() {
if(/Firefox[\/\s](\d+)/.test(navigator.userAgent) && new Number(RegExp.$1) >= 4) {
if(confirm("Are you Sure do you want to leave?")) {
history.go();
} else {
window.setTimeout(function() {
window.stop();
}, 1);
}
} else {
return "Are you Sure do you want to leave?";
}
});
Tested and working in firefox 11 as well. :)
My workaround is to show alert in onbeforeunload:
window.onbeforeunload=function() {
if ( /Firefox[\/\s](\d+)/.test(navigator.userAgent) && new Number(RegExp.$1) >= 4) {
alert("Blah blah. You have to confirm you are leaving this page in the next dialogue.");
}
return "Blah blah.";
}
(It 2 shows two dialogues in Firefox, one dialogue 1 elsewhere.)
Try implementing it with a confirm message,
window.onbeforeunload=function(){
return confirm("Are you sure??");
}
of 4 course when the user confirms then the FF4 3 message is shown, so you maybe better display 2 this once per site on login/visit. A cookie 1 should do the trick.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.