浏览器关闭时如何创建弹出窗口

2022-01-20 00:00:00 popup window javascript

我想在浏览器关闭或关闭标签页时打开弹出窗口.

I want to open popup window when browser closed or closed tabs.

推荐答案

window.onUnLoad= function (evt) { 
 //your code goes here
 window.open("yourpage/some link");
}

编辑注意:现在它将在浏览器的 onUnload 事件上调用.立即尝试

EDIT NOTE: Now it will be called on onUnload event of browser. Try now

尝试 window.onclose 事件:

Try window.onclose event:

在关闭浏览器时捕获事件

https://developer.mozilla.org/en/DOM/window.onclose

如何捕获浏览器窗口关闭事件?

参考资料:

http://dotnetacademy.blogspot.com/2010/09/call-function-in-javascript-before.html

在下面,您可以找到所有带有 javascript 窗口示例的事件:

On below like you can find all events with example of window for javascript:

http://www.java2s.com/Tutorial/JavaScript/0380__Window/windowonUnLoad.htm

相关文章