How do I test to see if links are external or internal? Please note:
I use this function for jQuery:
$.fn.isExternal = function() {
var host = window.location.host;
var link = $('', {
href: this.attr('href')
})[0].hostname;
return (link !== host);
};
Usage is: $('a').isExternal();
Example: https://codepen.io/allurewebsolutions/pen/ygJPgV