diff options
author | SkyArrow <tommy351@gmail.com> | 2012-01-24 18:05:55 +0100 |
---|---|---|
committer | SkyArrow <tommy351@gmail.com> | 2012-01-24 18:05:55 +0100 |
commit | b6b1bb5d2ab5247780116091f9bc864990e46699 (patch) | |
tree | 0c79e2a8ab3512583db280ec09b208ae79703309 /source | |
parent | d3b064cf56fa934073ad071ede4ec1ab312348f6 (diff) | |
download | octopress-theme-jeyzu-b6b1bb5d2ab5247780116091f9bc864990e46699.zip octopress-theme-jeyzu-b6b1bb5d2ab5247780116091f9bc864990e46699.tar.gz |
open external link in new window
Diffstat (limited to 'source')
-rw-r--r-- | source/_includes/custom/after_footer.html | 1 | ||||
-rw-r--r-- | source/javascripts/external.js | 13 |
2 files changed, 14 insertions, 0 deletions
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 @@ <script src="{{ root_url }}/javascripts/jquery.easing.1.3.js"></script> +<script src="{{ root_url }}/javascripts/external.js"></script> <script src="{{ root_url }}/javascripts/twitter.js"></script>
\ 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 |