By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

remember all windows I opened

P: n/a
Hi everybody,

how can I remember all windows I opened to close them with one click on a
button? (btw: do arrays exist in Javascript?)
Harrry
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Harald Weiser wrote:
Hi everybody,

how can I remember all windows I opened to close them with one click on a
button? (btw: do arrays exist in Javascript?)
Harrry

Keep the references returned by window.open(). Yes, arrays exist. You
want to use an array for this, do you?

http://devedge.netscape.com/library/...j.html#1008453

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Jul 20 '05 #2

P: n/a
Harald Weiser wrote:
Hi everybody,

how can I remember all windows I opened to close them with one click on a
button? (btw: do arrays exist in Javascript?)
Harrry

var myArray = new Array();

myArray[0] = window;
myArray[1] = window.self;
myArray[2] = window.opener;
//etc

Of course, replace these windows with the windows you care about.

Brian

Jul 20 '05 #3

P: n/a

"Bas Cost Budde" <ba*@heuveltop.org> schrieb im Newsbeitrag
news:c0**********@news2.solcon.nl...
Keep the references returned by window.open(). Yes, arrays exist. You
want to use an array for this, do you?


Ok. Thats exactly what I am doing now. BUT if I reload my main window, the
array is reinstantiated and all prior values are gone :-(
Jul 20 '05 #4

P: n/a
Harald Weiser wrote:
Ok. Thats exactly what I am doing now. BUT if I reload my main window, the
array is reinstantiated and all prior values are gone :-(


Yes, that is what happens when you reload the main window. Web pages
are stateless, meaning they do not retain data on reloads. There is a
mechanisim which can fix that... they are called cookies.

If you want a reloaded page to have data from the previous page, you
need to either use a cookie, or encode it in the search field of the
URL, which is really messy. (something like yourpage.html?<your data here>

I suppose you could also have a master window or frame, which retains
the data you need... But that is messy too.

Come to think of it, having multpile windows open at the same time is
messy to begin with :)

Brian
Jul 20 '05 #5

P: n/a
Harald Weiser wrote:
"Bas Cost Budde" <ba*@heuveltop.org> schrieb im Newsbeitrag
news:c0**********@news2.solcon.nl...

Keep the references returned by window.open(). Yes, arrays exist. You
want to use an array for this, do you?

Ok. Thats exactly what I am doing now. BUT if I reload my main window, the
array is reinstantiated and all prior values are gone :-(


Wenn du eine Array verwendet, warum noch danach fragen?

But that aside. <body onunload="cleanup()"> and then close all child
windows from the cleanup function.

Too harsh? Some other approach that comes to mind is some 'anchor
construct', where children windows keep an eye on the parent and start a
relinking procedure when the content refreshes.

Does the array die as well if it sits in an external script?

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.