在Web浏览器中捕获选项卡关闭事件?

J__*_*J__ 4 asp-classic

有没有办法知道用户是否关闭了Web浏览器中的选项卡?特别是IE7,还有FireFox等.如果包含我们网站的当前选项卡关闭,我希望能够从我们的asp代码处理这种情况.

小智 6

onbeforeunload也会在以下事件中被调用 -

* Close the current browser window.
* Navigate to another location by entering a new address or selecting a Favorite.
* Click the Back, Forward, Refresh, or Home button.
* Click an anchor that refers the browser to another Web page.
* Invoke the anchor.click method.
* Invoke the document.write method.
* Invoke the document.open method.
* Invoke the document.close method.
* Invoke the window.close method.
* Invoke the window.open method, providing the possible value _self for the window name.
* Invoke the window.navigate or NavigateAndFind method.
* Invoke the location.replace method.
* Invoke the location.reload method.
* Specify a new value for the location.href property.
* Submit a form to the address specified in the ACTION attribute via the INPUT type=submit control, or invoke the form.submit method.
Run Code Online (Sandbox Code Playgroud)

因此,如果您在关闭选项卡或浏览器窗口时尝试注销用户,则每次单击链接或提交页面时,最终都会将其注销.