0

I am opening a popup window from a page. The process goes like this:

var newwindow = window.open("mydomain.com/a.html", "Testing", 'height=600,width=800');
if (window.focus) { newwindow.focus() }

mydomain.com/a.html opens a popup mydomain.com/b.html

mydomain.com/b.html redirects the user to another site(say payment gateway) paymentgateway.com/authenticate.html

paymentgateway.com/authenticate.html redirects the user to mydomain.com/success.html

From mydomain.com/success.html I want to execute a function written on mydomain.com/a.html

I have written

window.parent.LaunchFunction();
window.close();

but it's not working. What can be the issue? Is it possible to achieve?

Om Sao
  • 7,064
  • 2
  • 47
  • 61
user1640256
  • 1,691
  • 7
  • 25
  • 48

1 Answers1

0

I'm offering another way - use the local storage for communication between apps at the same origin (same protocol+domain+port).

You can add listener, that is fired when somebody change any property in localstorage.

First instance is listening

window.addEventListener('storage', onStorageChange, false);

function onStorageChange (e) {
  if (e.key === 'messageText') {
    var messageText = localStorage.getItem('messageText');
    if (messageText) { // Prevent to call when fired by `removeItem()` below
      console.log('New message from another instance has come:', messageText);
      localStorage.removeItem('messageText'); // this will fires the `onStorageChange` again.
    }
  }
}

Second instance is sending the messages

localStorage.setItem('messageText', 'Hello from second app instance');
Martin
  • 696
  • 6
  • 7