Replacement for target=' blank' isn't working

So, since W3C has ‘dropped’ the target=‘_blank’ attribute, I decided to look up another solution to ensure that my link would open up into a new window.
However, when i entered the code given in here: http://www.ajaxblender.com/open-links-new-window-w3c-valid-target-blank.html
in my header, when clicking on the link my page just opens in the same window. I have tried both options!
Then, someone suggested that i use this

'[I]function externalLinks(){if(!document.getElementsByTagName){return;}var anchors=document.getElementsByTagName(“a”);for(var i=0;i<anchors.length;i++){var anchor=anchors;if(anchor.getAttribute(“href”)&&(anchor.getAttribute(“rel”)==“external”||anchor.getAttribute(“rel”)==“external nofollow”||anchor.getAttribute(“rel”)==“nofollow external”)){anchor.target=“_blank”;}}}
externalLinks();

this is what you would use for the links…

<a href=“blah” rel=“external”>
or <a href=“blah” rel=“nofollow external”>
or <a href=“blah” rel=“external nofollow”>

any of those will open in a new window’[/I]

which resulted in having code showing as text in the header and didn’t even work anyway! :nono:
help?!! :frowning:

this is the site for reference, i’m referring to the home page code http://www.ln-backups.co.uk/partsexport/

Quite a simple fix, you need to place the code in <script> tags like so:

<script type="text/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.getAttribute("rel")=="external nofollow"||anchor.getAttribute("rel")=="nofollow external")){anchor.target="_blank";}}}
externalLinks();
</script>

Let me know if that still doesn’t solve the problem for you.

It appears the W3c has removed the deprecated status for this attribute. I had to check, as it seemed a bit daft removing something that people would still use by doing it a different way.