检测跨域弹出窗口何时关闭 [英] Detecting when a Cross-Domain Popup Window Closes

查看:88
本文介绍了检测跨域弹出窗口何时关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生活在domainA.com上的javascript应用程序。为了验证用户身份并设置cookie,它会在domainB.com上打开一个弹出窗口。 (这类似于Twitter的@anywhere)。



如何检测domainB.com上的弹出窗口何时关闭并调用在domainA.com上打开它的javascript中的函数?



我尝试了各种方法,如window.opener,window.unload等,但遇到跨域限制。

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


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

这篇关于检测跨域弹出窗口何时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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