[thelist] check for existence of window by name?

AtdtXav atdtxav at yahoo.com
Mon Mar 25 14:21:01 CST 2002


I see!  I noticed this after I sent out the last message.  So by
declaring a reference we can check for the reference, but not
the name itself.  I wonder why this is.

Here is what I am ultimately doing now:
Checking for window.  if no window, open window.
Then (in QT) check for parentmovie.  If no parentmovie, run it.
change childmovie.
Meanwhile the return button on the parentmovie just blurs the
window.  This is for the narrowband version of a site I'm
working on, so this should save some time for the enduser.

Thanks for your assistance! :)

Scott Kennedy


--- "Cymbala, Greg" <Greg.Cymbala at Den.Galileo.com> wrote:
> Well, that confused me at first, too.  newWindow (on the 1st
> line of the
> script) is a JavaScript variable that is a reference to the
> window object
> that is created with the window.open() call.  I almost
> expected to be able
> to reference the newly created window by the name parameter of
> the
> window.open() method, but that didn't work.  That name doesn't
> seem to
> matter in this context.
>
> Here's how it works:
>
> We first declare the newWindow variable.  Since we don't at
> first assign any
> value or object to that variable, it's undefined.  Testing an
> undefined
> variable in an if statement returns false.  So, if the first
> if statement in
> the testWindow function returns false, we know that we haven't
> called our
> openNewWindow function.
>
> But, if the newWindow variable is not null or undefined, then
> we know it's
> probably a reference to our window object and we can test its
> closed
> property.
>
> There's no significance to the "my" and "new" prefixes.
>
> HTH,
> Greg
>
>
> -----Original Message-----
> From: AtdtXav [mailto:atdtxav at yahoo.com]
> Sent: Monday, March 25, 2002 12:22 PM
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] check for existence of window by name?
>
>
> 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>
>
>
> The information in this electronic mail message is sender's
> business
> Confidential and may be legally privileged.  It is intended
> solely for the
> addressee(s).  Access to this Internet electronic mail message
> by anyone
> else is unauthorized.  If you are not the intended recipient,
> any
> disclosure, copying, distribution or any action taken or
> omitted to be taken
> in reliance on it is prohibited and may be unlawful.
> The sender believes that this E-mail and any attachments were
> free of any
> virus, worm, Trojan horse, and/or malicious code when sent.
> This message and
> its attachments could have been infected during  transmission.
> By reading
> the message and opening any attachments, the recipient accepts
> full
> responsibility for taking protective and remedial action about
> viruses and
> other defects. Galileo International is not liable for any
> loss or damage
> arising in any way from this message or its attachments.
>
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


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



More information about the thelist mailing list