[英]Jquery beforeunload event not firing in any browser
It's not firing when I close the browser. 关闭浏览器时未触发。 I have researched the issue a lot and found similar kinds of solution, but it is still not working.
我已经对该问题进行了很多研究,找到了类似的解决方案,但是仍然无法解决。
$(document).ready(function(){
$(window).bind("beforeunload", function() {
return confirm("Do you really want to close?");
})
});
You can achieve this by using below piece of code. 您可以使用下面的代码来实现。
$(window).on('beforeunload', function(){
return confirm("Do you really want to close?");
});
If you want to perform some other things after user clicks yes, you can write that under 如果要在用户单击“是”后执行其他操作,则可以将其写在
$(window).on('unload', function(){
//DoSomething
});
I normally just use this: 我通常只用这个:
(function($){
$(window).on("beforeunload", function() {
return true;
})
})(jQuery);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.