我正在编写一个函数来检测用户是否使用广告拦截器。当我检测到它时,我会将其发送到 Site Catalyst (Omniture)。
问题是:一些广告拦截器使用黑名单来阻止请求,而我公司的 Catalyst url 就在这些列表之一中。 当我查看开发工具时,它们阻止了请求并显示 ERR_BLOCKED_BY_CLIENT。 有没有办法使用 JavaScript 检查请求是否被客户端阻止?
最佳答案
检测广告拦截器很容易检查这个答案,它可能会有所帮助 How to detect ad blocking and show a message
你可以看看这个可能有帮助 detect-adblocker
它是 timing answer 的实现
在 head 标记中的任何脚本之前添加此内容:
<head>
<title></title>
<meta/>
<!--adBlocker detection code - START-->
<script src="//adblocker.fortiapp.com/ads.js"></script>
<script>
(function (i, o, g, r) {
i[o] = (typeof i[o] == typeof undefined) ? g : r
})(window, 'adblocker', true, false);
</script>
<!--adBlocker detection code - END-->
// Other scripts
</head>
然后稍后使用它:
if (adblocker) {
// the add blocker is enabled
}else{
// ad blocker is not enabled
}
关于javascript - 使用 javascript 检查请求是否被用户阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35269855/