Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Location
    Newcastle
    Posts
    655
    Tokens
    50

    Default How-to: Detect ad-blockers on your site

    This is a quick and easy tutorial on how to detect if someone is using an ad blocker on your site (eg. Adblock Plus), and display them a message to nag them not to. Please do not use this tutorial to block access to your site entirely or display annoying alerts for those that do.

    Demo:
    Without an ad-blocker, an advert is displayed. With an ad-blocker, an alternative message is displayed.
    http://www.habbopfm.com/

    Step 1:
    Make a file named "adverts.js" on the root directory of your site (eg. www.yoursite.com/adverts.js) with the following code:
    Code:
    loa=true;
    Step 2:
    Add the following code just after your <body> tag:
    Code:
    <script>loa=false;</script><script src="/adverts.js"></script>
    Step 3:
    The final step is displaying the message - add the code below where your ads would be (you can change the style and text of the message):
    Code:
    <script>if(!loa)document.write("<div style='text-align:center;color:red;font-size:20px;font-weight:bold;background:#000;padding:10px;'>Our site is funded entirely by our sponsers.<br />Please do not block adverts on this page.</div>");</script>
    How it works
    This method of detection works by beating the ad-blocker at its own game - the blocker won't load anything it believes to be an advert, in this case "adverts.js", which simply sets a variable when it is loaded. If the variable isn't set, the file must have been blocked, and the message is displayed.

    Limitations
    This method can be circumvented by white-listing the "adverts.js" file. To prevent this, you could use several files with varying names.

  2. #2
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    Sponsors* and also a very nice script! Will help some people and their sites for sure.
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  3. #3
    Join Date
    Feb 2006
    Posts
    24,817
    Tokens
    63,679
    Habbo
    FlyingJesus

    Latest Awards:

    Default

    I don't know like.. anything at all about coding and such but would there not a way through this trick to just display the ads anyway to really piss everyone off
    | TWITTER |



    Blessed be
    + * + * + * +

  4. #4
    Join Date
    Nov 2006
    Location
    Narrich
    Posts
    5,687
    Tokens
    0
    Habbo
    Jamesy...

    Latest Awards:

    Default

    Quote Originally Posted by FlyingJesus View Post
    I don't know like.. anything at all about coding and such but would there not a way through this trick to just display the ads anyway to really piss everyone off
    Possibly. But really the idea here is to make people realise that as annoying as they may be, adverts are what provide the income many sites need to run, and maybe to reconsider.
    Ex-janitor. Might pop in from time to time, otherwise you can grab all my information from http://jamesy.me.uk/

Posting Permissions

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