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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

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:


The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger