This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Display alternate content when Adblock is in use
#3
RE: Display alternate content when Adblock is in use
I use something similar in all my projects that I build.
Sites with Adblock checking: (Enable/Disable your adblocker as needed to view header notice.)
http://www.mach-hosting.com/
http://www.supersimplecms.tk/
http://translate.supersimplecms.tk/

adblock_detector.css:
Code:
/* AdBlock Check */
#tester
{
    display: none;
    color: #ffffff;
}
#blocker_alert
{
    text-align: center;
    color: #F00;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    background-color: #FF0;
}
#blocker_ok
{
    text-align: center;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    background-color: #093;
}

adblock_detector.js:
Code:
document.write('<div id="tester">test advertisement</div>');

index.php:

Code:
<!-- [START] - adblock check -->
<script type="text/javascript" src="assets/adblock_detector.js"></script>
<script type="text/javascript">
    if (document.getElementById("tester") != undefined) {
        //document.write('<div id="blocker_ok">No <strong>AdBlocker</strong> detected! Thanks for truly supporting our site!</div>');
        } else {
        document.write('<div id="blocker_alert">We have detected that you have an ad blocker enabled! Please disable it and help support our work!</div>');
    }
</script>
<!-- [END] - adblock check -->

You can easily customize it to use different text or other banners or images. Wink
-TGates - Project Council

SEARCH the Forums or read theĀ DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by: pinguy


Messages In This Thread
RE: Display alternate content when Adblock is in use - by TGates - 12-04-2015, 01:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)