spacer
Yehuda Shiran April 18, 2000
Renaming the Current Window
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?

HTML doesn't provide a definition that assigns a name to the current window. Assigning a value to the window.name property (the name property of the window object) is the only way to set the name of the current window. Let's demonstrate it. The following code creates a simple button that sets the name of the window:

<FORM>
<INPUT TYPE="button" VALUE="Set Name to myWin" onClick="window.name = 'myWin'">
</FORM>

Now click the button:

Once you've clicked the button, the name of the current window becomes "myWin", and it remains the same unless we assign a different value to the name property. We can, for example, include links or forms in other windows that load in the current window by specifying TARGET="myWin". Click the following link to load a demonstration page in a new window:

Demonstration Page

If you previously set the name of the current window by clicking the button, the links in the new window should load in the current window. Here's the code for the links in the new window:

<A HREF="http://www.docjs.com/" TARGET="myWin">Home</A>
<A HREF="http://www.docjs.com/tips/" TARGET="myWin">Recent Tips</A>

For your convenience, use the following button to reset the name of the current window by setting its name property to an empty string (""):

You should be careful not to assign the same name to two different windows. If two windows are assigned the same name, the name ends up associated with one of the windows, and the other window's name is ignored.

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