remember all windows I opened

H

Harald Weiser

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
 
B

Brian Genisio

Harald said:
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
 
H

Harald Weiser

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 :-(
 
B

Brian Genisio

Harald said:
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
 
B

Bas Cost Budde

Harald said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top