XHTML-valid new window links

I always have to look this up. Run this on page load and give all 'a' tags the attribute rel="external" to create XHTML valid links that open in a new window. Goodbye target="_blank" function externalLinks() {if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } }

Friday, 27th February 2009» Permalink.

Tagged: and