Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://thepcspy.com/read/how_to_block_adblock/">http://thepcspy.com/read/how_to_block_adblock/</a></p> <p>With jQuery:</p> <pre><code>function blockAdblockUser() { if ($('.myTestAd').height() == 0) { window.location = 'http://example.com/AdblockNotice.html'; } } $(document).ready(function(){ blockAdblockUser(); }); </code></pre> <p>Of course, you would need to have a landing page for AdblockNotice.html, and the .myTestAd class needs to reflect your actual ad containers. But this should work.</p> <p><strong>EDIT</strong></p> <p>As TD_Nijboer recommends, a better way is to use the <code>:hidden</code> (or <code>:visible</code>, as I use below) selector so that <code>display: none</code> is also checked:</p> <pre><code>function blockAdblockUser() { if ($('.myTestAd').filter(':visible').length == 0) { // All are hidden, or "not visible", so: // Redirect, show dialog, do something... } else if ($('.myTestAd').filter(':hidden').length &gt; 0) { // Maybe a different error if only some are hidden? // Redirect, show dialog, do something... } } </code></pre> <p>Of course, both of these could be combined into one <code>if</code> block if desired.</p> <p>Note that <code>visibility: hidden</code> will not be captured by either as well (where the layout space stays, but the ad is not visible). To check that, another filter can be used:</p> <pre><code>$('.myTestAd').filter(function fi(){ return $(this).css('visibility') == 'hidden'; }) </code></pre> <p>Which will give you an array of ad elements which are "invisible" (with any being greater than <code>0</code> being a problem, in theory).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload