Forcing html page to reload after a little wait
I have a html page A and a link on the page that opens page B in a new window. How do I reload page A when clicking and opening this link?
EDIT:
I should have been clearer. Page B opens in a new window, not as a popup. The corresponding hyperlink has its target attribute equal to _blank. Taking the clue from the answers I got (thanks guys!), I tried setting onclick = "window.location.reload ()" and it works great.
However, I have a problem. Actually another question. How to ensure that page A reload is waiting for the page in the new window (page B) to load?
source to share
I'm not entirely sure if this is what you want based on your wording, but if you want to reload the open box from a link in the popup, try
self.opener.location.href = self.opener.location.href;
Edit based on your new comments, just use the above code in the load body of the new window
<body onload="self.opener.location.href = self.opener.location.href;">
source to share
Try the following:
<script type="text/javascript">
function openPage(elem) {
function reloadCurrentPage() {
location.reload();
}
var page = window.open(elem.href, '_blank');
page.onload = function() {
reloadCurrentPage();
}
if (/MSIE/.test(navigator.userAgent)) { // fix for IE
var timer = setInterval(function() {
if (page.document.readyState == 'complete') {
clearInterval(timer);
reloadCurrentPage();
}
}, 100);
}
}
</script>
<p><a href="second.html" onclick="openPage(this); return false;">second.html</a></p>
source to share