0
我使用此代码来通知用户他们将要去第三方网站,但我想排除一些外部URL。如何/在哪里可以在此代码中执行此操作?需要排除一些外部链接接收此通知
<script>
$('a').each(function() {
if (this.href !== "#" && this.href.indexOf('/') !== 0 && this.href.indexOf(location.hostname) === -1) {
$(this).attr('target', '_blank')
.click(function() { return confirm('NOTICE: You are leaving our website and will enter a website maintained by a third party. We are providing a link to the third party website solely as a convenience to you, because we believe that website may provide useful content. We are not, by referring or linking to the third party website, incorporating its contents into our own website. We do not endorse or guarantee, and we disclaim any responsibility for: the content, products or services offered on that website, its performance or interaction with your computer, its security and privacy policies and practices, and any consequences that may result from visiting that website. By clicking OK, you acknowledge this statement.');
});
}
});
});
</script>
我换成stackflow.com以上,我想从通知中排除的URL,全部换成了以前的代码本,但它不工作我。现在一切都没有通知打开。谢谢你的努力! – TDB
@TDB代码示例中存在小问题。 – Brian
完美!非常感谢你!!! – TDB