website/js/externalLinkHandler.js
2021-04-18 22:36:31 +02:00

9 lines
No EOL
283 B
JavaScript

document.onreadystatechange = function () {
document.querySelectorAll("a").forEach((element) => {
let href = element.href;
if(href.indexOf(location.hostname) === -1){
console.log(href);
element.target = "_blank";
}
});
}