2007-05-17, 04:32 PM
Well as you all know the target="_blank" with links is deprecated in XHTML 1.1.
So for you XHTML fanatics out there here is a solution to the
Here is a javascript solution, I made this for MyBB. As you all know it would be a lot more work then just this to make it validate as XHTML 1.1. But this can be used anywhere and on any page.
Then your link would look like.
So for you XHTML fanatics out there here is a solution to the
problem
.Here is a javascript solution, I made this for MyBB. As you all know it would be a lot more work then just this to make it validate as XHTML 1.1. But this can be used anywhere and on any page.
MyBB.externalLinks = function()
{
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.onclick = function(){ window.open(anchor.href); return false; };
anchor.onkeypress = function(){ window.open(anchor.href); return false; };
}
}
}
window.onload = MyBB.externalLinks; <!-- This will load on onload and set the links with onclick and onkeypress events. // -->
Then your link would look like.
<a href="http://www.mybboard.net" rel="external">MyBB</a>
It will find any link with rel="external" within the a tag.