Hi ... here is my situation: I am building an application that is
driven by a main menu. When the user chooses an option from the main
menu that spawns a new window (or module). From that(or any) module
window there is a menu where the user can choose to go to or switch to
any other module. So ... lets say that the main menu has 4 options.
The user chooses option 1 which will open a new window (replacing the
main menu). On that new window there is a menu where the user can
choose another module (which would spawn that module's window) .. and
so forth.
The problem is this: Let's say the user has all 4 modules open and
then chooses from module1 to switch to module2....well that spawns a
new window instead of just giving module2 focus. I have solved a big
portion of this using cookies to let me know if the window is already
open...however, when the user chooses a module window that is already
open then I am having trouble giving that window focus.
Pseudo-code is like this and included in an external .js file that is
loaded by each new page:
if (getCookie(page ID) == "")
{
alert(pageID + ' not open .. will now open');
setCookie(pageI D,'1','','','', '');
if (pageID=='first one')
Page1=window.op en(page,'','ful lscreen');
else if (pageID=='secon done')
Page2=window.op en(page,'','ful lscreen');
else if (pageID=='third one')
Page3=window.op en(page,'','ful lscreen');
}
else
{
alert(pageID + ' already open .. giving focus');
if (pageID=='first one')
Page1.focus();
else if (pageID=='secon done')
Page2.focus();
else if (pageID=='third one')
Page3.focus();
}
Now this works until it runs into a page that is already loaded and
then tells me that "Page1 is null or not an object". I understand why
this is happening but am not sure how to make the new window objects
accessable to the other windows.
Any help would be greatly appreciated.