Forum Moderators: open
I've noticed many variations of target identifiers inside anchor tags for a variety of purposes. I also notice that there seem to be several different identifiers that serve similiar purposes, examples:
<a target="_new" href="http://website.com"> link </a>
<a target="window" href="http://website.com"> link </a>
These seem to accomplish the exact same thing. Which is best supported to open the link in a new window while maintaining the parent site underneath? What purpose does the underscore serve?
Can anyone give more info on this: a list of other target tags... a browser support chart?
The following target names are reserved and have special meanings._blank
The user agent should load the designated document in a new, unnamed window._self
The user agent should load the document in the same frame as the element that refers to this target._parent
The user agent should load the document into the immediate FRAMESET parent of the current frame. This value is equivalent to _self if the current frame has no parent._top
The user agent should load the document into the full, original window (thus canceling all other frames). This value is equivalent to _self if the current frame has no parent.
Other names that page authors use for "target=" create a new window with that name, which often duplicates the effect of one of the "reserved" names listed above. The effect may be as intended, but it would be better to use one of the four reserved names if that's what is wanted. As far as I know, browser support is nearly universal on those four.
As I understand it, the purpose of the underscore is to minimize naming conflicts.
You can actually use that behaviour to your advantage: if you have a lot of pages that open in new windows, visitors will quickly end up with a cluttered taskbar and a messy desktop. Now, it may be essential that each document opens in a new window, but it may not be necessary for more than one of these documents to be open at a time. In that case, instead of:
<a href="new.html" target="_blank">
you can use:
<a href="new.html" target="my_special_window">
If the target is the same in each link, then every subsequent link will open in that window, instead of spawning a new one.
The only drawback is that, on some browsers, the window that has just loaded may not automatically come to the top of the stack, so it can appear as if the link has had no effect. One workaround is to include a small JavaScript widget that simply calls focus() on that window.