Discuz纯代码实现外链访问二次确认x2 插件功能效果 [复制链接]

moqu8 9月前

3115 0
将如下代码复制到文件footer.htm 任意JS代码下面即可

QQ截图20240809104246.png



function jumpToExternalLink(link) {
const message = '您即将离开魔趣建站,<b>新页面内容与魔趣建站无关,请注意网络安全</b>。<br/><p class="wot">即将访问:' + link + '</p>';
showDialog(message, 'confirm', '即将访问外部链接', 'window.open(\'' + link + '\', \'_blank\')', 0, 2, '本域:we.moqu8.com', '确定访问', '取消');
}
function forLinks() {
const links = document.querySelectorAll('a, [data-href]');
links.forEach((link) => {
const href = link.getAttribute('href') || link.getAttribute('data-href');
if (href && href.startsWith('http') && !href.includes(window.location.host)) {
link.addEventListener('click', (event) => {
event.preventDefault();
jumpToExternalLink(href);
});
link.setAttribute('target', '_blank'); // 在新窗口中打开链接
}
});
}
forLinks();




最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心