Created
January 2, 2010 03:20
-
-
Save melchoy/267366 to your computer and use it in GitHub Desktop.
handleExternalLinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleExternalLinks: function() { | |
var hostName = window.location.hostname; | |
var links = document.getElementsByTagName("a"); | |
for(var i = 0; i < links.length; i++) { | |
if(links[i].href.indexOf(hostName) == -1) { | |
var curTitle = (links[i].getAttribute("title")) ? links[i].getAttribute("title") + " - ": ""; | |
links[i].setAttribute("target", "_blank"); | |
links[i].setAttribute("title", curTitle + "opens in new window"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment