How can javascript be determined if AdBlock is enabled or not? Just have a slider and when AdBlock is turned on, then instead of it is empty space. Banners show the original size of 1x1 px.

  • why not rewrite the slider? Or does the slider show ads and therefore was banned :)? - KoVadim
  • one
    Reliably in any way. Adblock is up to you, and can basically rewrite your HTML as it pleases. In addition, I consider the task of combating advertising shutdown by the user to be deeply unethical: the client has the right to bypass the annoying content being imposed on him. If your content is not advertizing, contact the maintainers of block lists for false positives. - VladD
  • The slider simply shows the banners that are related to the shares. Of course, I agree about the annoying context, if it’s an advertisement, but when it’s just banners that report promotions on the site, I don’t see anything like that here. - TF03
  • 3
    @ TF03, as the question is now - it generally does not make sense. Well, you determine what is included adblok, then what? Throw out some stupid level message "do you have an adblock enabled, turn it off to work with our site"? ----- And I don’t even have an adblock, your banner URL is registered in a squid (this is for the question about the definition of an adblock in the answers below). And what, what is the use of this information to you, and what is a convenience for a site visitor? - user6550 2:55 pm
  • one
    I have an adblock blocking only banners, where the word banner is clearly indicated, adv, and so on, so just rename how the people advise and you will be happy. If banners are loaded from partners, then it is better to save them at home, and then display them on the site. If they change periodically, then load them with a script a couple of times a day, week, month, and so on. - MDJHD 4:41 pm

5 answers 5

I did it like this:

var o = document.getElementById('ad-detect'); var ad_visible = o && (o.style.display != 'none') && (o.width * o.height); 
 <img id="ad-detect" class="ads banner" src="/ads/banner.gif" alt="This must be hidden" /> 

banner.gif can 1x1 transparent / white ...

The task was to recommend an ad blocker to a visitor, if for some reason it is not yet: p

    There is such a feature:

     <img class="ad-detect" src="/img/ad.gif" /> <script> $(document).ready(function(){ var $adDetect = $('.ad-detect:visible').length; if ($adDetect) { console.log('adblock on'); } }); </script> "/img/ad.gif" - должна быть любая картинка 

      I somehow ran into the problem of html and http

      1. Remove class names and IDs that resemble ads from slider layout. ad-banner , banner , etc
      2. My pictures were in the /banners folder and the adblock interrupted their loading. Rename directory

        I saw one site, which with the help of js determines whether adblock is enabled, and if enabled, it displays a block saying that it is disabled. I do not know what the site is, but in js he had a link to this script

        • This is a script, some kind of dumb one ... I found a script on one site - they checked the height and width of the block, where the ads are, but for a slider this does not work ( - TF03
        • So you need to determine whether the adblock is enabled. or does the adblock block your slider? - zb '
        • pastebin.com/p1zNmC3q so simple. - lampa
        • Somehow the above example is much simpler =) - TF03

        You can use the following library: https://github.com/sitexw/FuckAdBlock

        Demo

        • This is not an answer, but a comment. To prevent admins from demolishing it, and you got balls into karma, it makes sense to supplement your answer with details about using the library. References to another resource in this case is not enough, it can change. - Alexander Muksimov