untested...but it should work.
> function externalLinks() > > if (!document.getElementsByTagName) return; > var anchors = document.getElementsByTagName("a"); > for (var i=0; i<anchors.length; i++) > if (anchor[i].getAttribute("rel") == > "external") { anchor[i].target = "_blank"; } > } > } > window.onload = externalLinks; >
Richard Czeiger wrote:
Hi guys - having a little problem with the whole external links in XHTML strict. Code's below - doesn't seem to be working - can you help out?
<a href="http://www.google.com.au/" rel="external">new window</a>
<script>
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;
</script>
Cheers :o) Richard
****************************************************** The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help ******************************************************
****************************************************** The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help ******************************************************