From 6bd786c704a52144b80474e9e8bc74ce68e08aec Mon Sep 17 00:00:00 2001 From: infominer33 Date: Sun, 7 Apr 2019 16:41:18 -0400 Subject: [PATCH] target blank --- _includes/scripts.html | 1 + assets/js/mod_outer_links.js | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 assets/js/mod_outer_links.js diff --git a/_includes/scripts.html b/_includes/scripts.html index 12340ce3..d67263b7 100644 --- a/_includes/scripts.html +++ b/_includes/scripts.html @@ -9,6 +9,7 @@ {% endfor %} {% else %} + {% endif %} diff --git a/assets/js/mod_outer_links.js b/assets/js/mod_outer_links.js new file mode 100644 index 00000000..aacd1afa --- /dev/null +++ b/assets/js/mod_outer_links.js @@ -0,0 +1,10 @@ +$(function () { + // add `target="_blank"` to outgoing links. + var host = document.location.host; + $("a[href]").each(function() { + var re = new RegExp(host, "g"); + if ($(this).attr("href").match(/\/\//) && !$(this).attr("href").match(re)) { + $(this).attr("target", "_blank"); + } + }); +});