How do I use a JavaScript code snippet to perform a redirect for Adblock users?

Simon J April 23, 2014
Pinterest Stumbleupon Whatsapp

I have a question about the article 3 Tactics For Dealing With Ad-Block Users On Your Site 3 Tactics For Dealing With Ad-Block Users On Your Site 3 Tactics For Dealing With Ad-Block Users On Your Site Leaving ethical discussions aside (since I made my views on that quite clear last time), it is nonetheless true that ad-blocking is a real problem for bloggers and site owners the world over whose only... Read More . I have now implemented the pastebin JavaScript to my website. I have changed div=id to div=class and accordingly changed #myAdContainer to .myAdContainer. I have inserted the JavaScript into the header of my site and have inbound 1 of my ads with the div class=”.myAdContainer”>

I then tried to disable AdBlock and enable it, which should be redirecting me to the URL I have written in the JavaScript – in this case the URL is http://disney.com/ . I don’t know why it is not working for me. Can you please help me? All help would be appreciated :)

Kind regards
Simon

Ads by Google

  1. James Bruce
    April 24, 2014 at 7:54 pm

    First: make it an ID, not a class. There's a reason it's like that - there can be only one named ID element. You should be able to surround your ad code with a specific ID, and just check one (perhaps you have more than one ad unit with the class, that's no good).

    Second: the script requires jQuery, and though most modern themes will include it, it's not certain. The snippet is also written in jquery "compatibility" mode - this is really designed for wordpress, so if you have a non-wordpress site and are sure you have included jQuery, try changing all instances of "jQuery" to "$".

    If you've tried both those, paste your URL here and I'll check the console.

  2. Oron J
    April 24, 2014 at 5:24 pm

    Fair point!

  3. Oron J
    April 23, 2014 at 10:21 pm

    Simon, you should really be asking this in the comments to the article itself. You're much more likely to get a response from people there.

    • Bruce E
      April 24, 2014 at 7:58 am

      That article was originally published more than a year ago. The comments close after 180 days, so he cannot look for answers there.