shield
11-24-2005, 10:09 AM
Just come across a bit of a problem...
XHTML Strict 1.0 has dropped the target="" tag meaning I cant open extrenal links in a new window.
I tried using the following Javscript to do it which worked but then it says that the code isnt valid XHTML. The javascript code throws it off...
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;
How can the above code be corrected to be compliant or maybe a different way around it?
Thanks
XHTML Strict 1.0 has dropped the target="" tag meaning I cant open extrenal links in a new window.
I tried using the following Javscript to do it which worked but then it says that the code isnt valid XHTML. The javascript code throws it off...
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;
How can the above code be corrected to be compliant or maybe a different way around it?
Thanks