Cookies and Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duane

    Cookies and Windows

    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.
  • kaeli

    #2
    Re: Cookies and Windows

    In article <2506960d.03121 51610.28a0c76a@ posting.google. com>,
    duane.elkins@se tel.com enlightened us with...[color=blue]
    >
    > 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.
    >[/color]

    You'd be better off giving the windows handles and checking for those.

    This is mine for a help menu.
    If the window is open, gives it focus and loads the help screen from an
    array that is populated elsewhere in the script. Modify it for your
    needs.
    Tested for NN6+/IE5+. I can't guarantee it works in any other browser.

    <script language="javas cript" type="text/javascript">
    var h_window = null;

    function openHelp(screen Name)
    {
    if (!h_window || h_window == null || typeof h_window == "undefined" ||
    h_window.closed || !h_window.docum ent)
    h_window = window.open("", "Help","height= 200,width=
    200,scrollbars= yes,resizable=y es");
    var doc = h_window.docume nt;
    doc.open();
    doc.writeln("<h tml><head><titl e>Help</title>");
    doc.writeln("<l ink rel='stylesheet ' type='text/css'
    href='myStylesh eet.css'>");
    doc.writeln("</head><body>");
    doc.writeln(h_a rray[screenName]);
    doc.writeln("</body></html>");
    doc.close();
    h_window.focus( );
    return;
    }
    </script>

    --
    --
    ~kaeli~
    She was engaged to a boyfriend with a wooden leg but broke
    it off.



    Comment

    Working...