How to detect ad blockers

From Lars' Site
Jump to: navigation, search


File: ad.js

adblocker = false;

File: index.html

<html>
  <head>
    <script type="application/javascript>
      var adblocker = true;
    </script>
  </head>
<body>
  Hello World
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
  <script src="ad.js"></script>
  <script type="application/javascript">
    $( document ).ready(function() {
      if (adblocker) {
        // Do whatever is necessary
      }
    });
  </script>
</body>
</html>