From 72d773c182ea3b6b1ece8f37c0e75316ba24b7c4 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 1 Dec 2017 23:06:32 -0500 Subject: [PATCH] Add base app.js, opening external links in new tabs --- app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 00000000..09c1a717 --- /dev/null +++ b/app.js @@ -0,0 +1,15 @@ +;(function(window, document, undefined) { + + "use strict"; + + // Open all external links in new tabs + var links = document.getElementsByTagName("a"); + + for(var i = 0; i < links.length; i++) { + var thisLink = links[i]; + if(thisLink.getAttribute("href") && thisLink.hostName !== location.hostname) { + thisLink.target = "_blank"; + } + } + +})(window, document);