问题描述:

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..

网友答案:

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.

相关阅读:
Top