可当孩子窗口关闭父窗口通知? (上差异域) [英] Can the parent window be notified when a child window closes? (on a diff domain)

查看:91
本文介绍了可当孩子窗口关闭父窗口通知? (上差异域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否父窗口时子窗口关闭通知? (在不同的域?)

Can the parent window be notified when a child window closes? (on a different domain?)

试图避开不工作在不同的领域时,window.opener。

Trying to get around the window.opener not working when on different domains.

我可以至少以某种方式当孩子窗口关闭通知?

Can I at least be notified somehow when the child window closes?

推荐答案

您不能直接被通知窗口关闭,但你可以计算出,当子窗口已通过检查的 关闭 通过的 window.open()

You can't directly be notified of the window closing, but you can work out when the child window has been closed by inspecting the closed property on the window object reference returned by window.open().

下面是通过轮询被关闭,这将显示子窗口的5秒内警报的例子关闭属性:

Here's an example that will display an alert within 5 seconds of the child window being closed by polling the closed property:

var win = open('http://www.google.com');
var intervalId = setInterval(function() {
        if (win.closed) {
            clearInterval(intervalId);
            alert('Window closed! Hoorah!');
        }
    }, 5000);

这篇关于可当孩子窗口关闭父窗口通知? (上差异域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆