[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to know that a window is still open

Weird.  The following works for me (I'm using Windows 95, BTW):

if (window.name == "")
	alert ("top level window")
	alert ("not top level window")

win = window.open ("", "newwin")  // just make a new window
if (win.name == "")
	win.alert ("top level window")
	win.alert ("not top level window")

-- Gordon

At 03:26 PM 3/11/96 +0100, you wrote:
>Few days ago I asked how to recognize that a given window is
>the topmost window, the 'last' one of all open Navigator windows.
>Gordon replied that "...Top level windows created when the browser 
>first opens or with File, New Browser never have a name....". That's
>clear. So I wanted less: just to be able to close the windows which I opened
>from my JS. It seemed to be very simple - let me again guote Gordon:
>Off the top of my head: If you open the window and pass it a name, like this:
>        window.open ("blah.html", "win1");
>then it will have a name.  You can test for the name with
>        if (window.name !="")
>                 you're in the top window
>But, it doesn't work. I tried to display window.name (exactly in this
>example window.win1) with alert and always I'v got '<undefined>'
>Does somebody know how to to this simple task? And can it be done
>in a way that I can close also windows not opened by my JS but
>those whose name I know (because I specified 'target' when calling them)?


For help about the list, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
List archives and pointer to FAQ: http://www.obscure.org/javascript/