用【大白自定义】做一个强制外链在新窗口打开并有安全提示的功能
xiunoa 2020-7-17

JS代码放到全局内容页尾(全局 : html > body ( footer_js_after ))

<script>!function() {
	$("a").each(function() {
		var url = $(this).attr('href');
		if (url.length > 0 && url.indexOf('http') >= 0 && url.indexOf(window.location.host) < 0) {
			// console.log(url);
			$(this).click(function() {
				$.confirm('即将离开网站,请注意您的帐号和财产安全。</br>' + $(this).attr('href') + '', function() {
					window.open(url);
				});
				return false;
			});
		}
	});}();</script>


最新回复 (2)
全部楼主
  • 土巴牛
    2022-1-1 2
    0
    不错的帖子!
  • chengxin
    3月前 3
    0
    楼主,你写得实在是太好了。我惟一能做的,就只有把这个帖子顶上去这件事了。 
返回