1 2 3 4 5 6 7 8 9 10 11 12 13
(function($){ var host = location.host; $('a').on('click', function(e){ var href = $(this).attr('href'), link = href.replace(/(https?:\/\/)(.*)\/(.*)/, '$2'); if (href.match('https?') && link != host){ window.open(href); e.preventDefault(); } }); })(jQuery);