Skip to content
Snippets Groups Projects
Verified Commit e9ee272e authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Open external links within iframe in _blank target

parent de48aeb8
No related branches found
No related tags found
1 merge request!1123Resolve "Finalise Vuetify app as SPA"
Pipeline #107829 canceled
......@@ -83,6 +83,33 @@
window.parent.postMessage({height: $(document).height()});
};
window.onresize = documentResizePostMessage;
function findLink(el) {
if (el.href) {
return el.href;
} else if (el.parentElement) {
return findLink(el.parentElement);
} else {
return null;
}
};
function clickCallback(e) {
const link = findLink(e.target);
if (link == null) {
return;
}
const newUrl = new URL(link);
const currentUrl = new URL(window.location.href);
if(newUrl.origin !== currentUrl.origin) {
console.debug("External link clicked. Redirecting to " + link + " in new tab.");
e.preventDefault();
window.open(link, '_blank');
}
};
document.addEventListener('click', clickCallback, false);
})
</script>
</body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment