[thelist] check for existence of window by name?

AtdtXav atdtxav at yahoo.com
Mon Mar 25 13:22:02 CST 2002


This is incredibly useful, greg, and I think I might be able to
make it from here, but could you explain to me a little bit
about how this works?

I see myNewWindow is the window name, and yet you're checking
for the existence of newWindow.  Why is this?  Is this a generic
search for a new window, or am I unaware of "my" and "new"
prefixes within javascript?

Thanks for your email
Scott

--- "Cymbala, Greg" <Greg.Cymbala at Den.Galileo.com> wrote:
> Try this in a page:
>
> <HTML>
> <HEAD>
> <SCRIPT LANGUAGE="JavaScript">
> var newWindow;
>
> // Try uncommenting/commenting the following line:
> //openNewWindow();
>
> function testWindow()
> {
> 	if (newWindow)
> 	{
> 		if (newWindow.closed)
> 		{
> 			alert("Not open.  Opening it.");
> 			openNewWindow();
> 		}
> 		else
> 		{
> 			alert("It's open!");
> 		}
> 	}
> 	else
> 	{
> 		alert("Window was never opened.  Opening it.");
> 		openNewWindow();
> 	}
> }
>
> function openNewWindow()
> {
> 	newWindow = window.open("http://www.google.com",
> "myNewWindow");
> }
>
> </SCRIPT>
> </HEAD>
> <BODY>
> <P><input type="button" onclick="testWindow()" value="Test"
> /></P>
> </BODY>
> </HTML>

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/



More information about the thelist mailing list