diff --git a/js/externalLinkHandler.js b/js/externalLinkHandler.js new file mode 100644 index 0000000..0feee1b --- /dev/null +++ b/js/externalLinkHandler.js @@ -0,0 +1,9 @@ +document.onreadystatechange = function () { + document.querySelectorAll("a").forEach((element) => { + let href = element.href; + if(href.indexOf(location.hostname) === -1){ + console.log(href); + element.target = "_blank"; + } + }) +} \ No newline at end of file diff --git a/js/script.js b/js/script.js index 632d041..dccfa63 100644 --- a/js/script.js +++ b/js/script.js @@ -4,6 +4,7 @@ require("./error"); require("./imgPreview"); require("./includeHTML"); require("./viewPost"); +require("./externalLinkHandler"); require("./customElements/ntpGraph"); require("./customElements/cookie");