open external links in new tab
This commit is contained in:
parent
73fa7ca454
commit
819f321489
2 changed files with 10 additions and 0 deletions
9
js/externalLinkHandler.js
Normal file
9
js/externalLinkHandler.js
Normal 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";
|
||||
}
|
||||
})
|
||||
}
|
|
@ -4,6 +4,7 @@ require("./error");
|
|||
require("./imgPreview");
|
||||
require("./includeHTML");
|
||||
require("./viewPost");
|
||||
require("./externalLinkHandler");
|
||||
|
||||
require("./customElements/ntpGraph");
|
||||
require("./customElements/cookie");
|
||||
|
|
Loading…
Reference in a new issue