Reload parent window from child window

JavascriptJquery

Javascript Problem Overview


How can I reload my child window's parent using jQuery?

Javascript Solutions


Solution 1 - Javascript

No jQuery is necessary in this situation.

window.opener.location.reload(false);

https://developer.mozilla.org/en-US/docs/Web/API/Window

Solution 2 - Javascript

You can use window.opener, window.parent, or window.top to reference the window in question. From there, you just call the reload method (e.g.: window.parent.location.reload()).

However, as a caveat, you might have problems with window.opener if you need to navigate away from the originally opened page since the reference will be lost.

Solution 3 - Javascript

parent.location.reload();

This should work.

Solution 4 - Javascript

if you want to simply reload the parent window of child window: This line code below is enough for that.

opener.location.reload(); 

if you want to reload parent window with query string (request) with old or new values. Following code will do the work.

if (opener.location.href.indexOf('?') > 0) {
      var baseUrl = opener.location.href.substring(0, opener.location.href.indexOf('?'));
      opener.location.href = baseUrl + "?param1=abc&param2=123";
}
else {
      opener.location.href = opener.location.href + "?param1=abc&param2=123";
}

this opener.location.reload(); is not required in above example.

Solution 5 - Javascript

You can reload parent window location using :

window.opener.location.href = window.opener.location.href;

Solution 6 - Javascript

  top.frames.location.reload(false);

Solution 7 - Javascript

This working for me:

  window.opener.location.reload()
  window.close();

In this case Current tab will close and parent tab will refresh.

Solution 8 - Javascript

Prevents previous data from been resubmitted. Tested in Firefox and Safari.

top.frames.location.href = top.frames.location.href;

Solution 9 - Javascript

window.parent.opener.location.reload();

worked for me.

Solution 10 - Javascript

This will work for refresh parent window from child window

window.opener.location.reload(true);

for some version of IE this will not work so you can set some delay

window.setTimeout(window.opener.location.reload(true), 3000);

Solution 11 - Javascript

this will work

window.location.assign(window.location.href);

Solution 12 - Javascript

For Atlassian Connect Apps, use AP.navigator.reload();

See details here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnitinView Question on Stackoverflow
Solution 1 - JavascriptChaosPandionView Answer on Stackoverflow
Solution 2 - JavascriptJustin JohnsonView Answer on Stackoverflow
Solution 3 - JavascriptAdem BüyükView Answer on Stackoverflow
Solution 4 - JavascriptARr0wView Answer on Stackoverflow
Solution 5 - JavascriptRaju RamView Answer on Stackoverflow
Solution 6 - JavascriptCG_DEVView Answer on Stackoverflow
Solution 7 - JavascriptRajesh KumarView Answer on Stackoverflow
Solution 8 - JavascriptCodeChapView Answer on Stackoverflow
Solution 9 - JavascriptPhanikumar JatavallabhulaView Answer on Stackoverflow
Solution 10 - JavascriptHarish RawatView Answer on Stackoverflow
Solution 11 - JavascriptAvnish alokView Answer on Stackoverflow
Solution 12 - JavascriptLukeSolarView Answer on Stackoverflow