Reputation: 61
I have two different pages both open in different tabs. On the first page I have a button, that when clicked page 2 will refresh. How can I make this possible with javascript? Any help will be much appreciated. page1.html
<script type="text/javascript">
function refreshpage2(){
location.reload();
}
</script>
<input type="button" value="refresh page 2" onClick=refreshpage2()">
Code above will refresh the page itself, what I want is reload page2 when button is clicked.
Upvotes: 1
Views: 5359
Reputation: 21
I assumed the you have two windows that the first window open second window that used to modified data in first window. You must open second window with window.open(url,'','') function and then refresh first window with function window.opener.location.reload(true);
Upvotes: 1
Reputation: 228
If these two pages are under you'r control you can put an ajax listener on page2 (the one that should be refreshed) and on page 1 put an ajax sender to notice page2's ajax to refresh the page. read this: http://prototypejs.org/doc/latest/ajax/Ajax/Updater/
Upvotes: 2
Reputation: 658
If you have reference to the page that you opened (second tab), you can use the reference to refresh the page. window.open might not open a new tab as it is designed to open a new browser window but the concept should be the same.
var newtab = window.open(url, '_blank');
now as long as you have access to the variable (global variable) newtab, you can use it to control the new tab.
newtab.document.location.reload(true);
Upvotes: 0
Reputation: 1881
As far as I know this is forbidden, because of security issues.
Upvotes: 0