Hacker News new | past | comments | ask | show | jobs | submit login

This is overkill. If you are asuming adblockers will remove anything with the id "adTeaser" (as per the code), just use that to display the message! No need for the "setTimeout" or even Javascript:

    <div id="adTeaser" style="position: absolute; z-index: 10000; ...">
      Please turn on your <a href="https://github.com/gorhill/uBlock#ublock-origin">ad blocker</a> to continue browsing this site
    </div>



This would still show the rest of the page though. The JavaScript solution hides everything else by setting document.body.innerHTML.


Sure, my mistake. Flip that "position:absolute" for "position:fixed". Note how I wrote "z-index:..." to imply an element covering the whole page.

Also note that activating your adblock does not disable the message in the OP, you'd also need to refresh the page since you are effectively removing the body.


Do any adblockers block content before the page is reloaded? I thought it'd be necessary to do network filtering.


You can make it a modal and blur everything else out.


Woooo, that's more work than either of the above solutions


It's like four HTML elements and like six CSS bits you can copy paste from the boatloads of other times you've done a modal.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: