3

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Caleb
  • 340
  • 2
  • 3
  • 11
  • Possible duplicate of [Can the parent window be notified when a child window closes? (on a diff domain)](http://stackoverflow.com/questions/781770/can-the-parent-window-be-notified-when-a-child-window-closes-on-a-diff-domain) – Simon Lieschke May 25 '16 at 16:40

1 Answers1

0

window.postMessage will help you on browsers that support it... https://developer.mozilla.org/en/DOM/window.postMessage

Mike Ruhlin
  • 3,546
  • 2
  • 21
  • 31