From b6b1bb5d2ab5247780116091f9bc864990e46699 Mon Sep 17 00:00:00 2001 From: SkyArrow Date: Wed, 25 Jan 2012 01:05:55 +0800 Subject: open external link in new window --- source/_includes/custom/after_footer.html | 1 + source/javascripts/external.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 source/javascripts/external.js diff --git a/source/_includes/custom/after_footer.html b/source/_includes/custom/after_footer.html index 5e3eaa8..7796caf 100644 --- a/source/_includes/custom/after_footer.html +++ b/source/_includes/custom/after_footer.html @@ -1,2 +1,3 @@ + \ No newline at end of file diff --git a/source/javascripts/external.js b/source/javascripts/external.js new file mode 100644 index 0000000..2501d9b --- /dev/null +++ b/source/javascripts/external.js @@ -0,0 +1,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); \ No newline at end of file -- cgit v1.1-2-g2b99