View Full Version : How to get a window reference?
Danne
02-24-2003, 03:19 PM
I have a window with links, some of these links open another window. If that window is already open, it opens that link in the same window.
The problem is, I don't want to reload this new window every time, I just would like to call a function inside it, if it is already open. To do so I need a reference to it. How can I get the reference to this window?
The opener window can be reloaded, so I can't just store it in a variable.
Hope it makes some sence...
requestcode
02-24-2003, 07:42 PM
If you are using JavaScript to open the new window like this:
NewWin=window.open(..)
Then you can reference the window using the variable NewWin. So to reference a function in that window you could try NewWin.function_name().
Danne
02-25-2003, 01:48 PM
Thanks for answering, but I meant it slightly different...
The problem is when the opener window has been reloaded, and I'd like to call a function in the new window.
Image this scenario:
1. Load main window.
2. Click on link that opens a new window (child window).
3. Click on the same link in the main window. This time the child window is already loaded, so I just want to call a function.
4. Click on a link in the main window, that reloads itself.
5. Click on that first link in the main window again. The child window is still loaded, so I only want to call a function again.
How can I get the reference to the child window this time?
king443
02-25-2003, 02:25 PM
Basically you want to get access to all the desktop windows - whether the main window created it or not.
I posted this question a while back. The reply was - cannot do it in JavaScript.
Danne
02-25-2003, 02:47 PM
well, that figures...:)
I thought there might be a way since there is a frames-collection, which is supposed to hold all window-objects created by the current document. The problem is how to reach it...
If I create the window like this:
var newWin=open("url.html","newWinName","");
..shouldn't it be possible to access a function in the new window using something like:
window.frames("newWinName").functionInNewWindow();
The name parameter seems to be different than the frame.name property, though...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.