I am working on a basic adblock script detection, and I came up with something similar that it should work. When creating an item on the page with the #adblock_detection_image identifier in Chrome with Adblock Plus running $('#adblock_detection_image').css('display') gives me a value of none , and running $('#adblock_detection_image').css('visibility') gives me the value hidden . When I launch them in a browser without Adblocker, I get inline and visible , as you might expect.
Having discovered this, I went further and tried to develop a solution. However, the problem is that the code that should run when a simple ad unit is detected does not run. The following is a snippet of code.
function isUsingAdblocker(classOfAd) { if(parseInt($(classOfAd).css('height')) <= 0) { return true; } else { $('body').append('<img id="adblock_detection_image" src="/textlink-ads-banner-advert-service.jpg" style="width: 0; height: 10px; position: relative; top: -1000px; left: -1000px;"/>'); if($('#adblock_detection_image').css('display') != 'inline') { return true; } else if($('#adblock_detection_image').css('visibility') != 'visible') { return true; } else { return false; } } } $(document).ready(function(){ if(isUsingAdblocker('#Ad-One')){ $('#Ad-One').html('<em>Please</em> disable your ad-blocking software to help support this website.<br/><span>(It\ our primary source of income!)'); $('#Ad-One').css('height', '90px'); } });
anon
source share