2022-04-29 12:23:26 +02:00
|
|
|
import '/assets/scss/page.scss';
|
2021-08-06 09:51:41 +02:00
|
|
|
|
2021-08-05 13:51:44 +02:00
|
|
|
document.addEventListener("readystatechange", event => {
|
|
|
|
if(event.target.readyState === 'complete') {
|
|
|
|
initExternalLinks();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-08-06 09:51:41 +02:00
|
|
|
|
2021-08-05 13:51:44 +02:00
|
|
|
function initExternalLinks() {
|
|
|
|
document.querySelectorAll('a').forEach(elem => {
|
|
|
|
if(isExternalURL(elem.getAttribute('href'))) {
|
|
|
|
elem.setAttribute('target', '_blank');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-12-31 18:22:31 +01:00
|
|
|
const isExternalURL = (url) => {
|
|
|
|
if(url.startsWith('/')) return false;
|
|
|
|
return new URL(url).origin !== location.origin;
|
|
|
|
}
|