在JavaScript中捕获弹出窗口的关闭事件 [英] Capture the close event of popup window in JavaScript
本文介绍了在JavaScript中捕获弹出窗口的关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在弹出窗口(使用 window.open
)关闭之前执行一些操作。
I need to perform some action before a popup window(using window.open
) closes.
Something喜欢会很好:
Something like will be good:
var new_window = window.open('some url')
new_window.onBeforeUnload = function(){ my code}
我如何实现这一目标?
推荐答案
只要弹出窗口网址与父页面在同一个域中,您的示例就会,并且您更改了事件全部小写:
Your example will work as long as the pop-up window url is in the same domain as the parent page, and you change the event to all lowercase:
var new_window = window.open('some url')
new_window.onbeforeunload = function(){ my code}
这篇关于在JavaScript中捕获弹出窗口的关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文