Reputation: 1662
I use the following onbeforeunload for call when the browser close.I get the alert properly also i get the Are you sure you want to navigate away from this page? message box automatically generate by the web browser.But I no need to display that message box when the browser is close.How to disable Are you sure you want to navigate away from this page? messagebox?
window.onbeforeunload = function(event)
{
if($.browser.msie)
{
alert('Test');
return false;
}
}
Upvotes: 1
Views: 6865
Reputation: 349042
Don't return a value, ie:
return;
Or, since the condition is a constant factor:
if($.browser.msie) {
window.onload = function() {alert('Test');};
} else {
window.onbeforeunload = function(event) {
return 'Are you sure to quit?'; // <-- Message is displayed in *some* browsers
}
}
If you're trying to implement a method which prevents the user from navigating away: There is no way to achieve that. It'd be a horrible experience to not be able to leave a page.
Upvotes: 2