-1

I'd like to know how I can have a link to an external page that is not visible to adblock users.

I have tried many things including giving it a div id="ad", and iframes. Is there maybe something I have missed?

Eric
  • 3
  • 1

1 Answers1

0

Here is a very simple example. I display the GoogleAdsense logo outside of the screen. If the image has no height it was blocked -> there is a AdBlocker

<html>
<head>
    <title>AdBlock Detector</title>
    <script type="text/javascript">
         //Is there a AdBlocker?
         function isAdBlocker(){
             var a = document.getElementById("adTest");
             return a.offsetHeight==0;
         }

         //Hide all Links tagged with 'add="true"'
         function protectLinks(){
             if(isAdBlocker()){
                  var links = document.getElementsByTagName("a");
                  for(var i=0; i<links.length; i++)
                       if(links[i].getAttribute("ad"))
                            links[i].style.display="none";
             }
         }
    </script>
</head>

<body onload="protectLinks()">

You can't see this link with enabled AdBlocker
<a ad="true" href="http://google.de">Link to Google</a>

<img id="adTest" style="position:absolute; left:-5000px" src="https://www.google.com/images/logos/adsense_logo_sm.png">
</body>
</html>

Insert the little Script and the "adTest" div in your Blog and give all links you want to protect a ad="true" attribute.

(And don't forgett to call the protectLinks() function after page is loaded.)

Fabian N.
  • 3,807
  • 2
  • 23
  • 46
  • I'm not actually running ads that are being blocked. I was just hoping for a simple html style markup that might cause adblock to flag a set of code to be hidden. I can understand the part there with the div markups, but anything above that has me confused, – Eric Jul 10 '13 at 01:53
  • Any ads I would use look like this: [code] Although none are currently active, I can turn them on if needed for this to work. – Eric Jul 10 '13 at 02:40
  • Ok I edited my answer. Look at it and be happy :-) – Fabian N. Jul 10 '13 at 11:39
  • Did you have this tested and working or am I just failing at setting it up right? – Eric Jul 10 '13 at 18:58
  • I tested it with Firefox 21.0 for Ubuntu – Fabian N. Jul 10 '13 at 19:09
  • Do you get any Javascript errors (in the error console / log) ? – Fabian N. Jul 10 '13 at 19:18
  • Blogger forces me to add closing tags before it lets me save it. I don't know if that is what is breaking the code or not. It makes me add a > at the end of and it also makes me do a /> after the google img and then it lets me save it. – Eric Jul 10 '13 at 19:25
  • hm yea i think that is the reason you could try to put the javascript in a extra file and include it with ` – Fabian N. Jul 10 '13 at 19:32