Created
March 13, 2012 20:45
-
-
Save stenvdb/2031459 to your computer and use it in GitHub Desktop.
JavaScript: Open links new window
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
$("a[href^='http:']:not([href*='" + window.location.host + "'])").each(function() { | |
if( !$(this).hasClass('fancybox') ) | |
{ | |
$(this).click(function() | |
{ | |
window.open(this.href); // pop a new window | |
return false; // return false to keep the actual link click from actuating | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment