在窗口/选项卡关闭之前Javascript注册窗口/选项卡关闭事件 [英] Javascript register window/tab closing event before window/tab close

查看:164
本文介绍了在窗口/选项卡关闭之前Javascript注册窗口/选项卡关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前已经/可能已经提出过,但是,据我记得,当时的问题并不令人满意^^

This has / may have been asked before, but, as far as I remember, the question was not satisfactory answered at that time ^^

我如何注册?使用Javascript进行窗口或制表符关闭事件?我已经尝试过body.onclose和body.onunload,以及其他几十个我自己编写的名字,并认为它们可能存在,但没有一个有效,或者,如果有的话,它只会在之后解雇窗口或标签已关闭。

How can I register a window or tab closing event with Javascript? I have tried body.onclose and body.onunload, and dozens others whose names I made up myself and thought they might possibly exist, but none of it worked, or, if it did, it only fired after the window or tab has been closed.

问题:
是否有任何方式在
窗口或标签之前注册此类事件被关闭了?它甚至不需要与所有浏览器兼容,只要它适用于Firefox。

Question: Is there any way to register such an event before the window or tab has been closed? It needn't even be compatible with all browsers, as long as it works with Firefox.

推荐答案

window.onbeforeunload = ...;

这篇关于在窗口/选项卡关闭之前Javascript注册窗口/选项卡关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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