Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWeb Content Preparation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Pre-Defined Window Targets

Most likely, you're already familiar with the target="_blank" attribute you can put into an "a" tag so the link opens a new window. (Your browser might open a new tab instead of a new window.)

Example:

<a target="_blank" href="http://example.com">Click</a>

The value "_blank" is a pre-defined target value. There are other pre-defined target values that can be used in "a" tag links. No JavaScript required. No PHP required. No other software required. Just HTML.

There are four pre-defined target attribute values:

Pre-defined
  Value  
Description
_selfLoad the page in the window, tab, or iframe where the link was clicked.
_blankLoad the page in a new window or tab.
_parentLoad the page in the parent window, tab, or iframe.
_topLoad the page in the top window or tab.

Below is more information about each of the pre-defined target attribute values. (The phrase "opens the page" means "opens the page that was linked to in the 'a' tag's href attribute." And "link" means "'a' tag link.")

  • _self

    When the link is clicked, the browser opens the page in the same window, tab, or iframe where the link is located.

    The target="_self" value is the default target value. Links open in the current window or tab unless the browser is told to do otherwise by a specific target attribute or JavaScript.

  • _blank

    When the link is clicked, the browser opens the page in a new window or tab.

    Generally, target="_blank" is implemented to open a new window or tab so the site visitor will return to the page the link is on when the new window or tab is closed.

  • _parent

    When the link is clicked, the browser opens the page in the parent window, tab, or iframe.

    A parent window is a window with an iframe or that spawned another window. When the link in the iframe or other window is clicked, target="_parent" causes the page to open in the parent window. If the window has no parent, then _parent defaults to _self.

  • _top

    When the link is clicked, the browser opens the page in the top window or tab.

    If a window contains an iframe or spawns another window, then the top window is the one with the iframe or that spawned another window (At this point, "_top" and "_parent" mean the same thing).

    Now, if that iframe or spawned window itself contains an iframe or spawns its own window, the top window is the window that contains the first iframe or spawned the first window in the chain. No matter how many iframes or spawned windows contain more iframes or spawned windows, the top window is the first window in the chain.

    If the window with a target="_top" link is not in an iframe and isn't a spawned window, then _top defaults to _self.

The target attribute may contain values other than the pre-defined ones. The iframe or other window with a name="..." attribute value that matches the link's target="..." value is where the page opens.

As an example, click this link to load an image of the Black Canyon of the Gunnison, South Dakota, USA into the iframe below.

Here's the source code to reproduce the example:

<a 
   target="example_URL" 
   href="//www.willmaster.com/library/external/ToPullIntoIframe.php">
click this link
</a>

<iframe 
   name="example_URL" 
   src="//www.willmaster.com/library/external/ToPreloadTheIframe.php";
   style="width:277px; height:362px; overflow:none; border:1px solid black; border-radius:9px; box-sizing:border-box; padding:none; background-color:#efefef;"
   scrolling="no">
</iframe>

The target attribute in the link has a value "example_URL" and the name attribute of the iframe tag has a value of "example_URL" (both colored blue). Therefore, when the link is clicked, it affects the iframe.

When a target attribute contains a value that doesn't match the name attribute value of an iframe or another window, and it isn't a pre-defined value, then the target attribute value defaults to _blank.

(This article first appeared in Possibilities ezine.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC