|
|
Q683 How do I iterate over all the opened windows?
irt.org | Knowledge Base | JavaScript | Window | Q683 [ previous next ] Q683 How do I iterate over all the opened windows?With extreme difficulty as there is not an object that holds all the open windows. When you open a window in JavaScript you use the following syntax:
The windowHandle holds a reference to the new window. So from the window that created the new window you can refer to the new window using the windowHandle, e.g. alert(windowHandle.title). You can refer back to the creating window (the opener window) from the new window by using the new windows opener property, e.g. alert(opener.title). This is the only means of getting information between windows. If you need to maintain information of all the open windows that you create then you'll need to create your own code to handle this for you. For example say we create a new window from the main window, and then from new window we create yet another window. In document1.htm:
and then in document2.htm:
Then the main window holds a reference to both of the new windows, the first new window holds a reference to the second new window, and both the new windows hold a refernce (opener) to their openers. Feedback on 'Q683 How do I iterate over all the opened windows?' |
-- div -->
|