A2S.in - Make Money Online - Powered by vBulletin

User Tag List

Results 1 to 1 of 1
  1. #1
    Moderator yipman's Avatar
    Join Date
    Mar 2018
    Posts
    151
    Coins
    0
    Thumbs Up
    Received: 111
    Given: 79

    Lightbulb How to detect AdBlock on your site?

    How to detect adblocking software on your site with little help of javascript. It works for both AdBlock and AdBlock Plus. So let's start.

    First you need to create advertisement.js file on your hosting. It is important that it is called that way because adblocking software will triggered by it. Put this code in it:

    Code:
    document.write('<div id="tester">an advertisement</div>');
    Now you have to insert this code right under <body> tag:

    Code:
    <script type="text/javascript" src="/advertisement.js"></script>
    
    <script type="text/javascript">
    if (document.getElementById("tester") == undefined){
        window.location = "http://yourlandingpage/adblock.html";
        }
    </script>
    With this code you will redirect users to your landing page where you can ask them to disable adblocking software in order to approach your page. This second part of this code can be edited any way you want and I will show it to you later in this post.

    And as final part you have to insert this code into your CSS file or into <style></style> in head of your HTML:

    Code:
    #tester {
    display:none;
    }
    So this is it. You have AdBlock detector on your site

    And now if you don't want to redirect users to landing page you can just warn them with pop up or with one paragraph. To do that you have to remove this part from original code:


    Code:
    window.location = "http://yourlandingpage/adblock.html";
    And replace it with this code for pop up:


    Code:
    window.alert("Your pop up warning!");
    And for paragraph you have to replace it with this code:

    Code:
    document.write('<p>Your paragraph waring!</p>');
    Of course, if you use paragraph as a warning, you have to place second part of original code where you want it to be.

    You can also edit it any way you like it.


    0 Not allowed! Not allowed!
    Last edited by yipman; 03-17-2018 at 02:24 AM.

    Relax and calm your mind. Forget about yourself and follow your opponent's movement.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •