Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload parent window from child window

No jQuery is necessary in this situation.

window.opener.location.reload(false);

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


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.


parent.location.reload();

This should work.


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.


You can reload parent window location using :

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

  top.frames.location.reload(false);