[英]Page redirection on page refresh not working
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. 我不知道我在想什么。
try this :) 尝试这个 :)
$(window).bind('beforeunload',function(){
alert("exiting");
window.location = 'http://www.google.com';
return false;
});
Most of the browser cannot handle anything after unload process is done . 卸载过程完成后,大多数浏览器无法处理任何事情 。
You should use beforeunload
event instead. 您应该改用beforeunload
事件。
$(window).bind('beforeunload', function() {
alert("exiting");
window.location = 'http://www.google.com';
return false;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.