处理浏览器在JavaScript中关闭? [英] Handle Browser close in JavaScript?

查看:124
本文介绍了处理浏览器在JavaScript中关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从JavaScript中捕获浏览器关闭事件?我不想在Page Unload事件或其他任何事情中这样做。必须在单击浏览器关闭按钮时处理。

Is there a way to trap the browser closing event from JavaScript? I don't want to do this in Page Unload event or anything. It must be handled on clicking the browser close button.

是否可以?

推荐答案

没有。您只有 onbeforeunload 事件,可用作原始javascript(jquery不包含此事件)。

No. You only have onbeforeunload event, available as raw javascript (jquery doesn't include this event).

如果你想尝试一下,尝试在这里发布一个答案,而不按发布你的答案尝试关闭浏览器窗口。

If you want to try it, try to post here an answer and, without pressing "post your answer" try to close the browser window.

这是访问该网站的最近方式关闭窗口事件。

This is the closest way to access the "close window" event.

这篇关于处理浏览器在JavaScript中关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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