spacer
Yehuda Shiran April 17, 2000
The name Property
Tips: April 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

With JavaScript we can discover the name of a window through its name property (IE3+, N2+). We can also set the name property of a frame or window (IE3+, N3+). Let's take a look at the following HTML document (showname.html):

<HTML>
<HEAD><TITLE>Display Name</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--

alert('The name of this window is: "' + window.name + '"');

// -->
</SCRIPT>
</BODY>
</HTML>

Take a look at the following links:

<A HREF="showname.html" TARGET="_blank">A New Window</A>
<A HREF="showname.html" TARGET="first">First Window</A>
<A HREF="showname.html" TARGET="second">Second Window</A>
<A HREF="showname.html" TARGET="third">Third Window</A>

The document showname.html consists of a script that displays the name of the window in an alert dialog box. Go ahead and test these links:

A New Window
First Window
Second Window
Third Window

The name property belongs to the window object. It can be used with any window object, including a frame. For example, the following statement sets the name of a frame window:

parent.frames[1].name = "right";

When working with frames, it's easy to access various levels of the window hierarchy. For more details, refer to Window References (November 7, 1999).

Learn more about windows creation and usage in Tutorial 1, Working with Windows.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business