Frage

I have been searching things about how to detect an ad-block and I found some things but none of them worked. How can I detect an ad-block in my web site and redirect the users? For example:

I have a ad-block, and go to www.lol.com it should redirects me to www.lol.com/adblock.php.

Edit

I just don't have ads, I'm developing a online game but users that have Adblock for some weird reason blocks the game. I just want to detect whether a user uses Adblock and tell these users to disable it.

War es hilfreich?

Lösung

If AdBlock hides your ads, you can just check if height of your ad containers is zero:

$(function() {
  if (!$("#yourAdContainer").height()) {
    window.location.href = "www.lol.com/adblock.php";
  }
});

UPDATE:

If you have no ads, you can create invisible block with id, known by adblock, of fixed height on page load, and check it's height. Example from my project:

$(document.body).append('<div id="advblock" style="position: absolute; opacity: 1; top: 0; left: 0;">hh</div>');
setTimeout(function() {
  if (!$('#advblock').height()) {
    window.location.href = "www.lol.com/adblock.php";
  }
  $("#advblock").remove();
}, 1);

Fiddle

Andere Tipps

Check if your div containing the game has a "ad like" class or id name.

Adblocks filters are big, so if you use class or id names that has

ad or advertising or something that could hint it was an ad, changes are it will get blocked because of existing filters. This has happened to me. Try renaming them.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top