Detect AdBlock (Anti AdBlock) | |
in: Web So/Code: Generico Data: 26/06/2018 Ora: 10.26:13 Articolo visualizzato: 2641 volte |
|
Hard times, AdBlock is a useful tool for surfers but penalizing for the owners of websites, blogs or other. Personally I do not gain anything but I pay the costs of the blog and allows me to continue writing. In addition to sponsored articles it is the only "entry". I think this year there will be a new layout of the sisto using boostrap, which allows me to make the site responsive and delete the mobile version. Today I explain very quickly the most common techniques to find out if the visit has installed AdBlock and then to show a message or whatever you want. Personally I prefer to warn that to prevent navigation, even if I fully understand that there are people who live there.
The detection of Adsense is one of the most common cases and is easily implemented, at the end of the page load we will check if the ads have been successfully uploaded otherwise we will show an altert or whatever you want. <script> window.onload = function() { setTimeout(function() { if ( typeof(window.google_jobrunner) === "undefined" ) { alert("Per sostenere questo sito disabilita AdBlock."); console.log("ad blocker installato"); } else { console.log("nessun ad blocker installato."); } }, 10000); }; </script>
<script>var isAdsLoaded=false;</script><script src="js/ads.js"></script><script> if (!isAdsLoaded) { console.log("The visitor is blocking ads"); } </script> The ads.js file will only be composed of the line isAdsLoaded = true; trivially it is based on a variable that only varies if the js file is loaded. ads.js can be included in any path. Salutoni | |
|
Articoli Correlati
Detect AdBlock (Anti AdBlock) |
Individuare AdBlock ( Anti AdBlock ) |
Cern - Catturata l'antimateria |
[PHP] - Convertire Codice Lingua a Lingua ( detect language code to language ) |
XBOX 720 - Prime indiscrezioni sulla nuova console, sistema anti-usato, Kinect 2 |
Commenti
Scrivi Commento