0

I have a popup window which opened from iframe, this iframe contains a script to open that window.

The iframe is inside a popup of a third party application. My problem is when I close the window I need to refresh the main page(Third Party). I've tried it without include it inside the third party application and it worked and refreshed, but when I put it inside the application it's not working.

I think maybe it will not work because I open the window from iframe so the opener is iframe not a page, but I don't know how to fix this problem.

This code that I use to refresh the page after closing the window:

function RefreshParent() {
  if (window.opener != null && !window.opener.closed) {
    window.opener.location.reload();
  }
}
window.onbeforeunload = RefreshParent;
MarioG8
  • 5,122
  • 4
  • 13
  • 29
Mike
  • 38
  • 7
  • 1
    If the opener of your iframe was on a different domain to the content of the iframe, then you will not be able to do what you're asking. – Rory McCrossan Dec 21 '21 at 09:23
  • @RoryMcCrossan Yes it's on a different domain, I feel that I'm hitting a wall with no success. Is there any solution to do it or it will not work at all ? – Mike Dec 21 '21 at 09:28
  • 1
    It will not work at all in client-side JS. It's a security restriction in modern browsers to prevent spoofing/phishing attacks. – Rory McCrossan Dec 21 '21 at 09:28
  • @RoryMcCrossan Thanks Rory, if I tried to do it server side it will work ? – Mike Dec 21 '21 at 10:33
  • 1
    There's no way to refresh a client-side page from the server side. – Rory McCrossan Dec 21 '21 at 10:39

0 Answers0