Skip to content

Instantly share code, notes, and snippets.

@stenvdb
Created March 13, 2012 20:45
Show Gist options
  • Save stenvdb/2031459 to your computer and use it in GitHub Desktop.
Save stenvdb/2031459 to your computer and use it in GitHub Desktop.
JavaScript: Open links new window
$("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