Created — forked from kaelig/application.js

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

JQUERY: Open external links and PDFs in a new window or tab

View application.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$(document).ready(function() {
// Open external links in a new window or tab
$(document).on('click', 'a[rel$="external"]', function() {
$(this).attr('target', "_blank");
});
$(document).on('click', 'a[href$=".pdf"]', function() {
$(this).attr('target', "_blank");
});
// Open all urls that don't belong to our domain in a new window or tab
$(document).on('click', "a[href^='http:']:not([href*='" + window.location.host + "'])", function() {
$(this).attr("target", "_blank");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.