Created
March 15, 2011 18:21
-
-
Save anonymous/871180 to your computer and use it in GitHub Desktop.
open links in new window.js
This file contains 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
<script type="text/javascript" charset="utf-8"> | |
/* <![CDATA[ */ | |
var openLinks = function () { | |
if (!document.getElementsByTagName) return; | |
var anchors = document.getElementsByTagName("a"); | |
for (var i = anchors.length - 1; i >= 0; i--) { | |
var theHref = anchors[i]; | |
if (theHref.hostname && theHref.hostname !== location.hostname) theHref.target = "_blank"; | |
} | |
}(); /* paste in your code and press Beautify button */ | |
if ('this_is' == /an_example/) { | |
do_something(); | |
} else { | |
var a = b ? (c % d) : e[f]; | |
} | |
/* ]]> */ | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment