I want to write a script which can determine whether a link is internal or external. This is simple from my perspective, all internal links are relative, so they start with
$(document).ready( function() { $('a[href^="http"]').not('a[href^="http://' + $(location).attr('hostname') + '"]').attr('target', '_blank'); });
Replace "http" with "https" if you need to