[英]Open new popup if tab is close event
i just want to open a new popup if the browserwindow is closed. 如果浏览器窗口关闭,我只想打开一个新的弹出窗口。 i have following code, but it doesnt seem to work
我有以下代码,但它似乎不起作用
<script type="text/javascript">
window.onbeforeunload = function () {
window.open("http://www.w3schools.com");
}
</script>
thanks 谢谢
You're looking for the onUnload
event, not onBeforeUnload
. 您正在寻找
onUnload
事件,而不是onBeforeUnload
事件。
onBeforeUnload
is expected to return a string which is used in an automatic confirm window. onBeforeUnload
应该返回一个在自动确认窗口中使用的字符串。 Word of warning, most pop up blockers will ignore calls to window.open
executed from an onUnload
event. 提示,大多数弹出窗口阻止程序将忽略从
onUnload
事件执行的window.open
调用。
See the mdc documentation here for onUnload
and here for onBeforeUnload
. 见这里的MDC文件
onUnload
和这里onBeforeUnload
。
The function you set as window.onbeforeunload must return a string that will be shown to the user in a messagebox. 设置为window.onbeforeunload的函数必须返回一个字符串,该字符串将在消息框中显示给用户。
window.onbeforeunload = function () {
window.open("http://www.w3schools.com");
return "something";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.