Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 685

Alert AdBlock users about adblock extension

$
0
0
Alert to Adblock Users to deactivate extension.
YOu can insert this code on your HEADERINCLUDE --> load every page or on your HEADER / HEADER_GUEST...or INDEX --> Only main page

I'm not a programmer, I just gathered a few pieces around

Code:
<div class="YOUR_CLASS">Alerts!&nbsp;</div> // - You can remove this
<script>
(function() {
    var message = "Your Message to AdBlock Users!";
    var tryMessage = function() {
            setTimeout(function() {
                if(!document.getElementsByClassName) return;
                var ads = document.getElementsByClassName('YOUR_CLASS'),
                    ad  = ads[ads.length - 1];
  if(!ad
                    || ad.innerHTML.length == 0
                    || ad.clientHeight === 0) {
                    alert(message);
                 //window.location.href = 'http://comunidade.bf4brasil.com.br/member.php?action=register'; "//"  Redirect users to where you want - You need to remove "//"
                } else {
                    ad.style.display = 'none';
                }

            }, 1800);
        }
        if(window.addEventListener) {
            window.addEventListener('load', tryMessage, false);
        } else {
            window.attachEvent('onload', tryMessage);
        }
})();
</script>

Viewing all articles
Browse latest Browse all 685

Trending Articles