website/js/externalLinkHandler.js

9 lines
283 B
JavaScript
Raw Normal View History

2021-04-14 21:30:14 +02:00
document.onreadystatechange = function () {
document.querySelectorAll("a").forEach((element) => {
let href = element.href;
if(href.indexOf(location.hostname) === -1){
console.log(href);
element.target = "_blank";
}
});
2021-04-14 21:30:14 +02:00
}