Published in: JavaScript
add onclick="window.open(this.href); return false;" to a Tag with rel="external"
function externalLinks() { if (! document.getElementsByTagName ) return; var anchors = document.getElementsByTagName("a"); var isIE = (document.documentElement.getAttribute("style") == document.documentElement.style); for (var i=0; i<anchors.length; i++) { if(anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external"){ if(isIE) anchors[i].setAttribute("onclick",new Function("window.open(this.href); return false;")); else anchors[i].setAttribute("onclick","window.open(this.href); return false;"); } } } window.onload = externalLinks;
You need to login to post a comment.
