"Magic" Target Names

There are four "magic" target names, which are also known as "Reserved Implicit Target Names". These four "magic" names have one thing in common: they all begin with the underscore (_) character. An underscore character at the beginning of a name is reserved in HTML solely for these "magic" target names.

"Magic" target names are used only as values of the TARGET attribute; they would NOT be used with the NAME attribute, because these "magic" target names are pre-built into the web browsers.

Of these four "magic" target names, only ONE is of any importance in frames programming today: "_top"

Example:

<a href="http://www.yahoo.com/" target="_top">Yahoo Link</a>

By setting the TARGET attribute equal to "_top", I am forcing the web browser to erase any existing frameset, and to display the new page at the "top" level of the browser window. To return to the previous frameset, the user need only click the "Back" button of the browser.

Here is an example which demonstrates the "_top" target name.

Anytime you link to a website which is NOT a part of your OWN website, you MUST use the "_top" target value to erase your frameset. The Web is SUPPOSED to allow for users to surf freely from site to site; if a user comes to your website and is unable to depart, or is trapped by your frameset and is only able to visit other websites through the confines of your frameset, you have designed your site inadequately. Trapping users in a frameset is considered bad netiquette, and may be the cause for expulsion from some web directories or other web linking services.

I really want to stress the previous point. You MUST permit users to depart from your frame site, you MUST NOT trap users within your frameset. Students always want to pop up new windows so that users may visit external sites without leaving their frameset, but this is ALSO considered bad netiquette. I have only seen a couple of professional sites which justified preserving a frameset, the frameset being required for purely technical reasons; one of these sites was an online distance-learning website which required the frameset to maintain login privileges for the students and online chat services from the main server during the class period, and expected users to quit out of their browser once the class period was over (Hmm... I wonder where I got THAT example...). You have to really get into some fairly advanced technical minutiae before you can justify preserving a frameset as users are browsing beyond your domain.

When designing using frames, just remember how annoyed YOU get when you can't escape from someone else's frame site, how irritated YOU feel when new windows keep popping up all over the place... (Can you tell that I have difficulty convincing students about this?)

As mentioned earlier, there are FOUR "magic" target names. Here is the list:

We've already talked about the importance of target="_top", so now let's discuss the rest.

_self is the default target name. If no TARGET attribute is set for a hyper-reference, the TARGET is by default equal to _self, which causes the HTML page in question to appear in the same frame as the hyper-reference which invoked it, as seen in this example from earlier in this module.

Since _self is the default TARGET setting, you will rarely be called upon to set the TARGET attribute equal to _self. If you reset the TARGET default value using the BASE tag, you may then be called upon to use the _self TARGET value, but not otherwise.

_blank causes a new, unnamed window to be opened to display the web page in question. This feature has the same disadvantage as invoking a target of a non-existent frame, namely, that the new window is USUALLY the same size, shape, and position as the OLD window, meaning that the user can't tell that a new window has opened, tries to click the "Back" button, is unable to return to the previous page, gets frustrated and quits out of the browser. Don't open new windows in this manner; only open new windows using JavaScript commands (as we shall discuss in a later module).

_parent is broken; Netscape and Microsoft no longer support this TARGET name in the same manner. _parent was used when frame pages appeared within other frame pages which appeared within OTHER frame pages (frame pages inside of frame pages inside of frame pages O MY!), something which is not commonly done. Because the features which the _parent TARGET name support are rarely, if ever, used, Microsoft and Netscape seem to feel no compulsion to repair their discrepancy in implementing this "magic" target name. Therefore, don't ever use target="_parent"!

If you want to see target="_parent" in action, I've got an example here. Internet Explorer uses Netscape 3's original implementation of this magic target name, while Netscape 4.x and above has used several different variants; try it for yourself!

Download the above example (.sit file).

Summary of Magic TARGET Values

_top brings up the new HTML page at the TOP level of the browser window, erasing the frameset; use it whenever you are linking to a page outside of your domain, or anytime you want to erase the extant frameset.

_self brings up the new HTML page inside the current frame, and is the default value for TARGET if no TARGET attribute has been explicitly stated.

_blank brings up the new HTML page inside a new, unnamed browser window, but should not be used for the reasons detailed earlier.

_parent is inconsistently implemented, is appropriate only for situations which rarely occur in the real world, and should not be used.

Main Menu