Skip to content Skip to sidebar Skip to footer

Reload A Child Page From Parent Page

I want a child page(that is opened from a link of parent page) will be reloaded every time from parent page when i click the Reload. I used this but this don't work when i refresh

Solution 1:

For security reason you can't read or change (including reload) in modern browsers a window/iframe that was loaded with the URL of another domain (like htt://google.com, supposing you're not a Google coder).

So you can't do that except if the distant server authorized it, which isn't frequent.

If the page is on the same domain, this works :

<li><ahref="#"title="alert-tab"onclick="myWindow=window.open('index2.html','_blank');">New Window</a></li><li><ahref="#"title="alert-tab"onclick="myWindow.location.reload();">Reload</a></li>

Be careful in your tests to always open in http:// (and not file://) as 2 local files are always considered as separate domains.

Note that if you give a name to your window, the next time it will be loaded will be in the same window, even if you reloaded the parent page in between :

<li><ahref="#"title="alert-tab"onclick="myWindow=window.open('index2.html','someName');">New Window</a></li>

So, if you want to have the child page reloaded when you reload the parent page, you could do something like this :

<li><ahref="#"title="alert-tab"id=mylink>New Window</a></li><script>functionopenPage(){
    myWindow=window.open('index2.html','someName');
    localStorage['open'] = 'yes';
}
window.onload = function(){
    document.getElementById('mylink').onclick=openPage;
    if (localStorage['open']=='yes')  myWindow=window.open('index2.html','someName');
    localStorage['open'] = 'no';
};
</script>

The idea is to check at loading if the child window was open last time and if necessary force its reload.

Of course, this works only if parent and child are served from the same domain.

Solution 2:

You can reopen the page, which in most cases have the same effect as reload.

<li><ahref="js.php"title="alert-tab"onclick="myWindow=window.open('http://www.google.com','_blank');">New Window</a></li><li><ahref="#"title="alert-tab"onclick="myWindow=window.open('http://www.google.com','_blank');">Reload</a></li>

Post a Comment for "Reload A Child Page From Parent Page"