Last active
December 31, 2015 17:09
-
-
Save lunaroja/8018473 to your computer and use it in GitHub Desktop.
Clean Link Helpers
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
$(document).ready(function(){ | |
// Open any external links in new window | |
$("a[href^='http']:not([href*='" + window.location.hostname + "'])").attr("target","_blank"); | |
// Open links to PDFs in new window | |
$('a[href$=".pdf"]').attr("target","_blank"); | |
// Don't open and links with an empty hash | |
$("a[href='#']").on("click",function(e) { e.preventDefault(); }); | |
// Don't open any links with a disabled class on them | |
$("a.disabled").on("click",function(e) { e.preventDefault(); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment