浏览器关闭事件而非页面刷新/重新加载事件 [英] browser close event not page refresh/reload event

查看:100
本文介绍了浏览器关闭事件而非页面刷新/重新加载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要检测浏览器关闭事件,而不是页面刷新/重新加载事件

i need to detect the browser close event only not page refresh/reload event

我已经尝试过了,但是在两种情况下都可以正常工作

I have tried this , but in both condition its working

    $(window).bind('beforeunload',function(){

        });

 window.onbeforeunload = function (e) {

        }
$(window).unload(function() {  

});​

推荐答案

没有捕获浏览器Close Event的特定方法.

There is no specific method for capturing browser Close Event.

您只能在当前页面的unload上捕获.

You can only capture on unload of the current page.

当您尝试refreshreload页面时,这也可以使用.

Which also works when you try to refresh or reload the page.

这篇关于浏览器关闭事件而非页面刷新/重新加载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆