document.addEventListener("click", function(e) {
let a = e.target.closest("a");
if (!a) return;
const href = a.getAttribute("href");
if (!href) return;
// Only for external websites
if (href.startsWith("http") && !href.includes(location.hostname)) {
e.preventDefault();
// Method 1
window.location.assign(href);
// Method 2 (fallback)
setTimeout(function () {
window.open(href, "_self");
}, 100);
}
}, true);