rel = "external"
So XHTML is all evil and doesn’t allow target = “_blank”. Let’s try rel = “external” and see what happens with a bit of JavaScript ![]()
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName('a');
for (var i=0; i < anchors.length; i++) {
var anchor = anchors[i];
if ( anchor.getAttribute(’href’) &&
anchor.getAttribute(’rel’) == ‘external’ )
anchor.target = ‘_blank’;
}
}
window.onload = externalLinks;
We get opening in new windows using rel=”external”
6:57 pm
Oooo….this is good to know about.
8:55 am
This post is wrong: your underscores are swapped. That should be target=”_blank” . That opens a new window, and it validates as XHTML 1.1 Strict.
11:57 am
Heh, I blame… um… the late hour on that faux pas. Still however, the target attribute is only part of XHTML 1.0 Transitional and is not in XHTML 1.0 Strict or XHTML 1.1. That much I know to be true. And there is no such thing as XHTML 1.1 Strict
10:19 pm
woohoooo! this is exactly what i needed. 1.1 strict? what is he talking about??? lol.
3:27 am
As Seth said, XHTML allows you to use target=’_blank’ if it’s XHTML 1.0 Transitional. Why bothering with usage of something which doesn’t allow this attribute. Use XHTML 1.0 Transitional and it will be fine
. I found this web standard to be very usable.
3:35 pm
So, now that we are talking in here again, I’d just like to point out that, effectively, you still have invalid XHTML 1.0 Strict / XHTML 1.1.
So, while the w3c validator will say its valid code, you’re just using a more sneaky way to get around the rules rather then actually following them, aren’t you?