Passing a JavaScript variable/object reference from one page to another?...

Giganews Newsgroups
Subject: Passing a JavaScript variable/object reference from one page to another?...
Posted by:  dbruzzo…@attbi.com (Davide Bruzzone)
Date: 25 Jul 2003

Greetings all...

Here's a description of the problem that I'm trying to solve:

- I have a Web page from which users can open one or more other
windows.
- From that web page, the user can then select another part of the
application thereby loading a different page into the original browser
window (from which one or more "child" windows may have been opened).
- When the user logs out of the application, regardless of whether
they are on the page on which they started (in the original window),
or they are in another part of the application, we need to be able to
close all the windows that the user opened from the original window.

We're using IE 6.0...

My problem is that I can't find a way to pass the object that points
to a window that was opened on one page into another page...

For example:

- I start out on a.html
- I open a window... My code looks something like this:

var myWindow = window.open(...

- In the original browser window (which is currently displaying
a.html) I click a link that takes me to b.html
- In b.html I may need to close myWindow, but I don't have a reference
to it, so I can't call myWindow.close()

Is there any way to pass the myWindow object into b.html (or to store
it in some "global" area from which it can be accessed by any page)?
Either that, or am I missing something far more obvious?

I've started thinking about a number of solutions to this problem, but
none of them are anywhere near elegant...

Any suggestions would be greatly appreciated...

Cheers...

Dave Bruzzone

Replies