Window A opens window B
Window A opens window C
On Window C (after user action) I 开发者_StackOverflow社区need Window B refreshed.
some more explanation: yes. Window A is the main calendar. window B is opened manually and is smaller and shows stats about the calendar (window A)
When user clicks on a calendar event in window A then Window C opens. And when the user changes info on Window C then Window B (stats) needs to update.
First of all I have to warn you that what you are trying to achieve is not a good practice.
Many browsers are opening new tabs instead of new windows, which can influence the availability of the window.opener
. Although this depends heavily on the browser settings.
So first of all you should test to see that your code is really opening new windows, not new tabs.
Now, in a.html you should have this:
var windowB=window.open("b.html");
var windowC=window.open("c.html");
In c.html you should have this:
function openNewPage() {
window.opener.windowB.location.reload(true);
}
and call the openNewPage() function on user interaction.
You need to set references to each other the child windows to each other. Here's a simple demo.
var b= window.open('');
var c= window.open('');
b.test=function() {
alert('Function in window B');
};
c.test=function() {
b.test();
return false;
};
$(b.document).find('body').append('<div>Window B. <a href="#" onclick="return test();">Click here</a></div>');
$(c.document).find('body').append('<div>Window C. <a href="#" onclick="return test();">Click here</a></div>');
http://jsfiddle.net/9ZCX3/25/
精彩评论