open external links in new tab

This commit is contained in:
Jonas Leder 2021-04-14 21:30:14 +02:00
parent 73fa7ca454
commit 819f321489
2 changed files with 10 additions and 0 deletions

View file

@ -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";
}
})
}

View file

@ -4,6 +4,7 @@ require("./error");
require("./imgPreview");
require("./includeHTML");
require("./viewPost");
require("./externalLinkHandler");
require("./customElements/ntpGraph");
require("./customElements/cookie");