Detect AdBlock with JQuery

Some bloggers like me maybe so pissed to know that our ad revenue is decreasing dramatically after introduction of Ad blocking plugin (like AdBlock/Adblock Plus, etc). But lucky I found a way to ask the audience to disable the plugin when detected. In this case, I used jQuery to detect adBlock.

I used JQuery to detect ad blocking plugin for my other website. Here’s the code I used:

First, I put my ads inside a DIV, and name it “yourcode”.

<div id="yourcode"><!-- your ad code ---></div>

And put this code just below it:
<script type="text/javascript">
     jQuery(document).ready(function(){
          if (jQuery('#yourcode').height() == 0) {
               alert('ADBLOCK IS ACTIVE!');
          }
     });
</script>

That’s the simple detection method. But, you can change the code above as per your need.

For example, I edited the code in andiim3.com to hide some contents (download links) when the code detected adBlock and show a dialog asking audience to disable the ad blocking plugin.

I put extra code just after “alert()” to trigger some action after audience clicked the “OK” button.

Need help? Leave a comment below..

Andi Setiawan

Loving husband - Caring Father - Slap bet Commissionaire (I wish) find my complete profile on: http://andisetiawan.com/about-me http://facebook.com/andiim3 - http://gplus.to/andiim3 - http://andiim3.com

Share
Published by
Andi Setiawan

Recent Posts

Dedicated Blog for Dobby and Luna

Dobby and Luna have been part of our lives for the past years. They have…

2 years ago

Demo Site For My Projects

In the year 2021, I've completed some paid projects. Some of them are more technical,…

2 years ago

GlassTime – Glassmorphism WordPress Theme

Based on the GlassTime Bootstrap template, here I present glassmorphism WordPress Theme free to download.This…

3 years ago

GlassTime : Glassmorphism Responsive HTML5 Template

This HTML5 template is using Glassmorphism UI design language which is now trending for 2021…

3 years ago

Daftar Desa, Kecamatan, dan Kode Pos Buleleng – Bali

KecamatanKode POSBanjar81152Buleleng81119Busungbiu81154Gerokgak81155Kubutambahan81172Sawan81171Seririt81153Sukasada81161Tejakula81173Klik pada nama kecamatan untuk melihat daftar desa masing-masing. Sumber: kodepos.andiim3.com

3 years ago

Ninja diganti ADV

Ada yang bilang "semuanya akan mati matic pada akhirnya". Bener aja, sekarang tuntutan transportasi sehari-hari…

4 years ago

This website uses cookies.