You can use below javascript code to detect if adblocker is turned on
1 2 3 4 5 6 |
var newImg = new Image(); newImg.src = "https://1.bp.blogspot.com/-AA25pykjU0w/WT0oG85MmOI/AAAAAAAAHHw/I628lgK1QYAJdDRLprIIsCRVt5L0n7XagCLcB/s1600/ad.jpg"; newImg.onerror= function(){ var classe=document.getElementById('block'); classe.innerHTML="<span class=\"alert alert-danger\" role=\"alert\"> Please Disable Your Adblocker </span>"; } |
What We are doing is : We are creating a image object (newImg) and loading an image which have name 'ad'. Which will be blocked by the adblocker. Then checking if there is any error in loading the image(newImag.onerror). If there is an error then we are displaying the error message in the HTML tag with id 'block'. You can customize the message as per your needs. Working in latest browsers but didn't tested in old browsers.