What does _top in the hyperlink target do?
target=:
_top
: Opens the linked document in the full body of the window
_blank
: Opens the linked document in a new window or tab
_self
: Opens the linked document in the same frame as it was clicked (this is default)
_parent
: Opens the linked document in the parent frame
framename
: Opens the linked document in a named frame
http://www.w3schools.com/tags/att_a_target.asp
If the link is in an iframe
, the new webpage will not be loaded in the iframe
but instead the browser will open the page in the window itself
It's a browsing context name.
A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top.
Take a look at the matrix here, which describes the behavior of the target
attribute in different scenarios.
The practical effect is that _top
references the topmost window (technically the top level browsing context).
<a href="http://foo.com" target="_top">a link</a>
tells the browser to navigate to "foo.com" not in its own frame, but in the topmost frame. If the current frame is the topmost frame, the URL will open in the same window.
See also: Browsing Contexts (if you're in the mood for some deep reading).
target="_top"
will open the link at the top level of all defined framesets.
as @hamon said
Example to use _top with jQuery
If your site is contained in a frameset
$(document).ready(function() {
if(top.location != location) {
$('a, form').each(function() {
if(!this.target) {
this.target = '_top';
}
});
}
});
So.. All links in your site gonna open in new window not in the frame (Credit)