Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Created September 12, 2012 05:08
Show Gist options
  • Save zackn9ne/3704409 to your computer and use it in GitHub Desktop.
Save zackn9ne/3704409 to your computer and use it in GitHub Desktop.
jQuery Safemode Open External Links In New Window for WordPress
<!-- asdfsript works in footer-->
<script>
jQuery(document).ready(function($) {
// $() will work as an alias for jQuery() inside of this function
});
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment