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?

0


source to share


5 answers


Something like that:



<a href="javascript:window.open('pageB.htm');window.location.reload();">open page b</a>

      

+3


source


The easiest way is to do

<a href="# " onClick="window.open('newPage.htm','window','width=400,height=200')">link</a>

      



If I remember correctly that I should open the window, then, since the refund was not canceled, reload the page load.

+1


source


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;">

      

+1


source


0


source


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>

      

0


source







All Articles