dongzhi1851 2014-10-10 18:42
浏览 115
已采纳

如何防止用户在我的网站上使用广告拦截器? [关闭]

Hey any one know how to prevent users to use ad blocker on my site.I just want to request them not to use it on my site..

  • 写回答

1条回答 默认 最新

  • dos8410 2014-10-10 18:49
    关注

    Make a Javascript file called advertisement.js with this code:

    var noadblock = true;
    

    Include it on your page somewhere:

    <script type="text/javascript" src="advertisement.js"></script>
    

    The idea is that adblock will block the file called advertisement.js and your var will never be created. So you can use this to take action based on whether the var exists or not:

    window.onload = funtion(){
        if (noadblock){
            // no adblock
        }else{
            // adblock detected, do stuff here
        }
    }
    

    Updated cus somone in the comments had a better idea.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程