I'm really new to JS, and I'm trying to learn about it.
I've seen many questions about this, but there seems not to be a unique answer to solve this issue, nor a definitive code to implement.
Browsing though several NFL sites I see they have implemented an interesting code and I'd love to know how it works and if it is possible to replicate it.
Their detect-blocked-ads.js shows this:
//detect if there is an adblock cookie set (has this test been performed before?)
//if not perform the test and save the cookie
$nflcs.detectBlockedAds = function() {
if($nflcs.cookie('adblocker') == null) {
$nflcs('body').append('<div id="adblock-notice">We noticed that you may have an Ad Blocker turned on. Please be aware that our site is best experienced with Ad Blockers turned off. <a href="javascript:void(0);" class="close">[X]</a> <div style="clear:both;"></div></div>');
$nflcs('body').append('<div id="adblock-test" class="bannerAd">This is a test banner</div>');
$nflcs('#adblock-notice a').click(function(e) {
$(this).parent().fadeOut('fast');
});
if((typeof($nflcs('#adblock-test').css('-moz-binding')) != 'undefined' && $nflcs('#adblock-test').css('-moz-binding').indexOf('elemhidehit') !== -1) || ($nflcs('#adblock-test').css('display') == 'none')) {//adblocker in use
$nflcs('#adblock-notice').fadeIn('fast');//show the adblock notice
$nflcs.cookie('adblocker',true,{expires: 3});//save that this test has been performed for 3 days max
}
else {//adblocker not in use
$nflcs.cookie('adblocker',false,{expires: 3});
}
$nflcs('#adblock-test').remove();
}
}
Then they display a CSS colored block on top of the page if there is an adblock enabled.
<div style="display: block;" id="adblock-notice">We noticed that you may have an Ad Blocker turned on. Please be aware that our site is best experienced with Ad Blockers turned off. <a onclick='s_objectID="javascript:void(0);_1";return this.s_oc?this.s_oc(e):true' href="javascript:void(0);" class="close">[X]</a> <div style="clear:both;"></div></div>
I'd love to know how to call this function to show the code or message attached in the JS file.
Thanks