Reputation: 334
I want to redirect to a page on page refresh. Below is my script.
$(window).unload(function () {
alert("exiting");
window.location = 'http://www.google.com';
return false;
});
Its not working. I don't know what I am missing.
Upvotes: 0
Views: 1416
Reputation: 4541
Most of the browser cannot handle anything after unload process is done.
You should use beforeunload
event instead.
$(window).bind('beforeunload', function() {
alert("exiting");
window.location = 'http://www.google.com';
return false;
});
Upvotes: 1
Reputation: 2047
try this :)
$(window).bind('beforeunload',function(){
alert("exiting");
window.location = 'http://www.google.com';
return false;
});
Upvotes: 1