Firefox和Chrome应该如何触发浏览器关闭事件 [英] how should fire browser close event for firefox and chrome
本文介绍了Firefox和Chrome应该如何触发浏览器关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个网站,当用户单击浏览器关闭按钮时需要提醒....
我想要此代码用于Firefox和chrome....
谁能帮我...
I have create a website which need alert when user clicks browser close button....
I want this coding for firefox and chrome....
Can anyone help me......
推荐答案
以下代码对我来说非常完美
Hi,
Following code work perfectly for me
(窗口).unload(function(){ 如果(事件 .clientY < 0 ){ // 在关闭窗口时可以执行任何操作. } });
(window).unload(function() { if(event.clientY < 0) { //do whatever you want when closing the window.. } });
希望对您有帮助
祝你好运
快乐编码
hope it will help u
good luck
happy coding
这篇关于Firefox和Chrome应该如何触发浏览器关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文