website/js/externalLinkHandler.js

10 lines
308 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){
element.target = "_blank";
element.setAttribute("rel", "noreferrer");
2021-04-14 21:30:14 +02:00
}
});
}