Are you sure when adding a link with that target=”_blank”, it looks something like this:
<a href="http://maddox.xmission.com/" target="_blank">Maddox</a>
Just was curious, cause I don’t see why it’s not passing validation…it’s not spitting out errors for me on my blog, for that… :/
spencerp
This little bit of javascript does the trick for me, just change the domain to match your own, but beware that it opens ALL links outside the specified domain in a new window, but since it’s all javascript, it is fully valid up-to and including XHTML 1.1.
function makeNewWindows() {
if (!document.links) {
document.links = document.getElementsByTagName('a');
}
for (var t=0; t<document.links.length; t++) {
var extlinks = document.links[t];
if (extlinks.href.search(/http/) != -1) {
if (extlinks.href.search('/www.DOMAIN.com/') == -1) {
extlinks.setAttribute('target', '_blank');
}
}
}
}
window.onload = function(e) {makeNewWindows();}
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}
Cheers,
Michael.
@spencerp-yours may not be of the “strict” type, not sure but mine was of “strict” and it did not validate.
@niziol-Thanks for that bit of code—much appreciated!!
@spencerp-yours may not be of the “strict” type, not sure but mine was of “strict” and it did not validate.
Oh ok..I didn’t dig too deep on that, just was posting a quicky type response that I thought was of “some” possible help, suggestion or whatever.. =)
niziol, thanks for posting that as well. =) Going to bookmark this thread for later reference purposes.. =)
spencerp
My pleasure!
the target=”blank” attribute will validate with XHTML 1.0 Transitional, but not with anything above that (such as string or XHTML 1.1). 🙂
Cheers,
Michael.
the target=”blank” attribute will validate with XHTML 1.0 Transitional, but not with anything above that (such as string or XHTML 1.1). 🙂
Thanks for clarifying that.. 🙂 I guess I was just so used to using the XHTML 1.0 Transitional that I didn’t realize it. But now I know and I’ll remember it and this post for reference purposes then..lol. 🙂
That point is well noted, I have just tried it on my Test Blog3 using this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
And just recieved that validation error as well. =) Thanks again niziol, and I’ll remove that target=”_blank” then after awhile.. =)
spencerp