website/js/externalLinkHandler.js

9 lines
308 B
JavaScript

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