Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect adblock and javascript [closed]

I wish to detect adblocking software on my website and ask users to disable adblock by redirecting. The only way I found was using Javascript.

  1. Is there any other way of detection ?

  2. If not, how do I detect if Javascript is disabled and redirect them to a certain page ?

like image 429
Dheeraj Avatar asked Jan 30 '11 00:01

Dheeraj


1 Answers

To detect if the user is blocking ads, all you have to do is find a function in the ad javascript and try testing for it. It doesn't matter what method they're using to block the ad. Here's what it looks like for Google Adsense ads:

if(typeof(window.google_render_ad)=="undefined") 
{ 
    //They're blocking ads, do something else.
}

This method is outlined here: http://www.metamorphosite.com/detect-web-popup-blocker-software-adblock-spam

To redirect all users with javascript disabled, simply put this code in the head of your HTML:

<noscript>
    <meta http-equiv="refresh" content="5;url=http://newsite.com/">
</noscript>
like image 71
Beau Avatar answered Sep 30 '22 14:09

Beau