I was just on w3Schools looking at target and found that it is no longer supported by any of the major browsers. A brief google search did not reveal the reason for this? Should
$(function () {
$("a").attr("target","_blank");
});
It's still allowed in regular HTML and transitional xHTML, but not in strict xHTML anymore. The idea behind this was that users like to choose for themselves how to open a link, and not have it forced upon them by the browser.
The <a> tags target attribute is still supported by all major browsers (@w3schools).
I went to w3School and i found that The target attribute is no longer deprecated in HTML5.
It is supported by most major browsers. It's just not part of the strict HTML specifications from the W3C. However, browsers implement it even when using a strict doctype. This fact is sometimes used to emulate its behaviour with JavaScript while keeping HTML that still validates:
<a href="http://www.google.com" rel="external">This is an external link</a>
And:
var links = document.getElementsByTagName('a');
for(var i=0, len=links.length; i<len; i++){
var a = links[i];
if(a.getAttribute('href') && a.getAttribute('rel')=='external'){
a.target='_blank';
}
}
In transitional doctypes, no workaround is required.
target
attribute is supported by all browsers.
It has been removed from HTML4 Strict and XHTML 1 Strict, because these don't allow frames, and because forcing new windows on users isn't always good idea (e.g. Back button in new window will be disabled, which confuses some users).
target
has been added back in HTML5. You can use it, but don't abuse it.
It's OK if you want to open help page in new window on page that has a long form (you don't want users to lose content of the form), but it's not OK to force every link in new window in hope it'll make your page harder to leave.
And please don't try cheat validator by using scripts to open new windows. It gives same negative effect to users (or even worse if it breaks when JS is disabled), but is harder to detect and control than target
.
BTW: Please don't treat W3Schools as authoritative. They're not affiliated with W3C in any way, and their tutorials often contain mistakes.