问题描述
我有一个生活在domainA.com上的javascript应用程序。为了验证用户身份并设置cookie,它会在domainB.com上打开一个弹出窗口。 (这类似于Twitter的@anywhere)。
如何检测domainB.com上的弹出窗口何时关闭并调用在domainA.com上打开它的javascript中的函数?
我尝试了各种方法,如window.opener,window.unload等,但遇到跨域限制。
I have a javascript application that lives on say domainA.com. In order to authenticate a user and set cookies, it opens a popup window on domainB.com. (this is similar to Twitter's @anywhere).
How do detect when the popup on domainB.com closes and call a function in the javascript that opened it on domainA.com?
I've tried various methods like window.opener, window.unload, etc, but run into cross domain limitations.
window.postMessage will help you on browsers that support it...https://developer.mozilla.org/en/DOM/window.postMessage
这篇关于检测跨域弹出窗口何时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!