Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How to request users to disable Ad Blocker for my website in Q2A site?

+3 votes
81 views
asked Oct 4 in Q2A Core by eswar22
How to request users to Block Ad Blocker in Q2A site?. In Wordpress we have some plugins where we can ask user to distable adblocker for my site. But how can we do this for Q2A site.
commented Oct 5 by eswar22
can someone please help on this.

1 Answer

+1 vote
answered Oct 5 by esqeudero

Try below script on your body tag. 

<script>
(function(){
  var test = document.createElement('div');
  test.innerHTML = '&nbsp;';
  test.className = 'adsbox';
  document.body.appendChild(test);
  window.setTimeout(function() {
    if (test.offsetHeight === 0) {
        window.alert('PLEASE, disable your AdBlocker !!!');
    }
    test.remove();
  }, 100);
})();
</script>

You can add it from theme-base.php file.

Find public function body_script() and add there.

 

...