Javascript 如何在浏览器关闭时创建弹出窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4067796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create popup window when browser close
提问by Pradeep Singh
I want to open popup window when browser closed or closed tabs.
我想在浏览器关闭或关闭标签时打开弹出窗口。
回答by Dr. Rajesh Rolen
window.onUnLoad= function (evt) {
//your code goes here
window.open("yourpage/some link");
}
EDIT NOTE: Now it will be called on onUnload event of browser. Try now
编辑注意:现在它将在浏览器的 onUnload 事件上调用。现在试试
Try window.onclose event:
尝试 window.onclose 事件:
https://developer.mozilla.org/en/DOM/window.onclose
https://developer.mozilla.org/en/DOM/window.onclose
How to capture the browser window close event?
References:
参考:
http://dotnetacademy.blogspot.com/2010/09/call-function-in-javascript-before.html
http://dotnetacademy.blogspot.com/2010/09/call-function-in-javascript-before.html
On below like you can find all events with example of window for javascript:
在下面,您可以找到所有带有 javascript 窗口示例的事件:
http://www.java2s.com/Tutorial/JavaScript/0380__Window/windowonUnLoad.htm
http://www.java2s.com/Tutorial/JavaScript/0380__Window/windowonUnLoad.htm