Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3958536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:37:16+00:00 2026-05-20T02:37:16+00:00

I placed a piece of ads code in a div and at the bottom

  • 0

I placed a piece of ads code in a div and at the bottom of page, I have javascript code that checks for the offsetHeight size of the div. If “0” is returned, I could safely assume that the ads has been chewed by ad blockers

What I’m trying to do is, I want an image to appear in the spot where the ads was supposed to be showing when the ads was blocked.

Any idea how to do this?

Edit: Forgot to show the codes

<div id="div_bleh">
ads goes here
</div>

<script type="text/javascript">
function check_blehsize()
{
    if (document.getElementById("div_bleh").offsetHeight == 0)
        // do stuff
}
window.onload = check_blehsize;
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:37:17+00:00Added an answer on May 20, 2026 at 2:37 am

    Here’s an example which I tested against a very common ad blocker – Firefox’s Adblock Plus (using the EasyList filter):

    Live Demo (edit)

    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">
    .innocent-class {
        background: url(http://www.google.com/images/logos/ps_logo2.png);
        width: 240px;
        height: 400px
    }
    
    
    .justForTesting, .advertise_ads {
        width: 240px;
        height: 400px;
        background: #fff
    }
    </style>
    </head>
    
    <body>
    
    <div class="innocent-class"> <!-- just don't call it "advertContainer" :) -->
        <div class="advertise_ads justForTesting">
            advert here!
        </div>
    </div>
    
    </body>
    </html>
    

    When Adblock Plus finds an element with a class (for example) .advertise_ads, it will hide that element.

    If it does, the “please don’t block my ads!” background-image (in this case, the Google logo) from the parent element will be visible.

    If the advert isn’t blocked, the advert will cover the replacement image.

    Try changing advertise_ads to something else such as sdpfjsdfjp, and the advert will be visible.

    I imagine this technique will also work with most other ad blockers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am getting errors in this piece of code; I have placed the error messages
I have the following piece of JS code within a function that responds to
I have a nice piece of functional and tested Ruby code that I would
I have a problem with a piece of JavaScript code - a snippet is
I have a code that fetches a list from DB. Using that returned array
I have placed an image on the master page. I see the image at
I have an absolutely placed div with an embedded YouTube video inside of it.
Wikipedia says that A piece of code is said to be exception-safe, if run-time
I'm trying to create a fairly simple piece of JavaScript that displays a random
I have a piece of jQuery that will not load at all for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.