Create an Account
username: password:
 
  MemeStreams Logo

MemeStreams Discussion

search


This page contains all of the posts and discussion on MemeStreams referencing the following web page: Adblock detection. You can find discussions on MemeStreams as you surf the web, even if you aren't a MemeStreams member, using the Threads Bookmarklet.

Adblock detection
by Acidus at 11:23 pm EDT, May 13, 2009
if (document.images) {
  var currImg;
  var ImgFound = 0;
  var LinkFound = 0;
  //alert("checking images..");
  for (var d=0; d < document.images.length; ++d) {
    currImg = document.images[d];
    if (currImg.src.indexOf("banner") > -1) {
     ImgFound = 1;
    }
  }

  if (!ImgFound || AdBlockTest) {
     if(deny) {	 
       location = "/sorry.html";
       window.location(location);		
     } else {
	document.getElementById('warning').style.visibility = 'visible';
     }
  }

}

Interestingly simple. All the Adblock detection I've seen in the past checked CSS properties of elements surrounding an ad to see if the ad was rendered or not. This implementation requires a separate <img src> tag but I imagine this could be refactored into a (new Image()).src call and have a pure JavaScript solution.


 
 
Powered By Industrial Memetics