Skip to content

Instantly share code, notes, and snippets.

@Vitzkrieg
Last active August 29, 2015 14:12
Show Gist options
  • Save Vitzkrieg/ccfa4143821128fe9c7a to your computer and use it in GitHub Desktop.
Save Vitzkrieg/ccfa4143821128fe9c7a to your computer and use it in GitHub Desktop.
Set External Link Targets to Blank
function externalLinksTargetBlank() {
jQuery('a:not([href*="' + document.location.hostname + '"])').attr('target', '_blank');
}
function lastElementLoaded() {
if (jQuery('.lastelement').length > 0) {
externalLinksTargetBlank();
} else {
setTimeout(tweetsLoaded, 500);
}
};
(function ($) {
$(document).ready(function (e) {
externalLinksTargetBlank();
lastElementLoaded();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment