-3

I've seen the code before somewhere else but I can't find it. I would like to find a way of notifying users via the Notification bar to add an exception for a website.

BlindingDawn
  • 274
  • 1
  • 4
  • 19

6 Answers6

1

I don't have the code off-hand but the basic strategy to do this is to attempt to execute code that ad-block pro normally blocks and then check if it ran successfully or not. If not, you can display a notification to the user.

Jeremy Battle
  • 1,638
  • 13
  • 18
1

You could try this...

var image = new Image();

image.onerror = function() {
   alert('C\'mon, the ads pay for this site :(');
}

image.src = 'http://example.com/known-url-adblock-blocks';

..or...

alex
  • 479,566
  • 201
  • 878
  • 984
1

I don't know about launching a notification bar, but I think the method that this site uses would work... basically, they add a background image behind the ad that shows through when the ad is blocked:

enter image description here

Mottie
  • 84,355
  • 30
  • 126
  • 241
0

An alternate way of doing this really simply is checking your ad containers height. You can then detect in almost one line of jQuery!

function checkAds()
{
  if($(".ad-container").height()=="0")
  {
    // Show notification here!
  }
}
jduncanator
  • 2,154
  • 1
  • 22
  • 39
0

My easiest solution with jquery is:

    $.ajax({
        url: "/Scripts/custom/advertisement.js", // this is just an empty js file
        dataType: "script",
        success: function () {
          // user doesn't use adblock
        }
    })
    .fail(function () {
       // user uses adblock
    });

advertisement.js just contains nothing.

Luca Steeb
  • 1,795
  • 4
  • 23
  • 44
0

You could throw a javascript alert up based on any of the methods found on Stackoverflow already:

Community
  • 1
  • 1
Beau
  • 1,771
  • 1
  • 15
  • 20