I am opening a popup window from X.jsp and the popup is represented by Y.jsp. The second jsp has a button. What I would like to do is to refresh the parent page (the one that launches the popup) once this button is hit. The Save button below will call a method in the backing bean "copyScriptForVersion" and I close the popup on button click. How could I also refresh the parent window after closing the popup?
<h:commandButton type="submit" value="Save" action="#{copyScriptForVersion.SaveAction}" onclick="window.close()"/>
I tried adding window.opener.reload() like this onclick="window.close(); window.opener.reload();", but that didn't work.
I also tried adding the following body onUnLoad="window.opener.location.reload(1);">
But, I got "window.opener.location is null or not an object" error.
First of all, you should do window.close()
as a LAST action in the onClick handler. Otherwise, it's possible it will never get executed.
Second, if reload() doesn't work, try:
window.opener.location.href = window.opener.location.href; window.close();
Please note that this may cause problems if the parent page was produced as a result of POSTing a form.
Try this it may help other as well,,
`new = window.open(url);
new.focus();
check = setInterval(function() {
if (new.closed) {
window.location.reload(true)
}}, 1000);`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.