3 ms·
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
by franciscop 8y ago
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>
- dmurray 8y agoThis would still show the rest of the page though. The JavaScript solution hides everything else by setting document.body.innerHTML.
- hawkice 8y agoYou can make it a modal and blur everything else out.
- franciscop 8y agoSure, 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.
- flingo 8y agoDo any adblockers block content before the page is reloaded? I thought it'd be necessary to do network filtering.