Header
Detect AdBlock (Anti AdBlock)
in: Web  So/Code: Generico Data: 26/06/2018
Ora: 10.26:13
Articolo visualizzato: 209 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.


Let's analyze the first case: Adsense

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>


Obviously where the jquery alert is present it will be possible to insert any warning even in the limiting form, that is, obscuring the site or other.



The second case is based on loading a js file named ads.js. The adblockers try to prevent the loading of this js and then through a small check we can verify the loading


<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

Commenti Commenti (0) | User Autore: Guido Camerlingo (Guiz)
Tags: AdBlock anti script individuare detect visitatori sito web web site script





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
Codice Verifica

Commento massimo 5000 caratteri.(Tutti i campi contrassegnati da * sono obbligatori).

   

Ricerca

Glossario Naviga nel nostro glossario!
Scopri il gergo dei Geek!


 ULTIMI ARTICOLI

114 giorni fa

 [EN] Last Articles

 Siti Amici

Visita il Blog Roll
Contattaci! Diventa nostro amico!



 Hot Downloads

3772

 Categorie

85
163
58
87
13
2
20
36
1
2
5
5
128
7
24
15
62
45

 Code

11
11
3
6
2
24
1
7

 Games

19
45
13

 GUIDE


 Novità Downloads

64
58
3772

 Tags Cloud

suonerie iphone eliminare 2010 antifurto 4 avvio creare tipi architettura model csv un ringtone show inclusione model 3gs a book



 CopyRight

Valid XHTML 1.0 Transitional CSS Valido! [Valid RSS] Creative Commons License


Geek-Blog by Flavio Mandato, Giuseppe Vaccaro, Guido Camerlingo, Stefano Natale, Domenico Cavallo is licensed under a Creative Commons Attribuzione-Non opere derivate 2.5 Italia License.
Based on a work at www.geek-blog.it.
Permissions beyond the scope of this license may be available at http://www.geek-blog.it/

Disclaimer - Responsabilità - Pagina generata in 0.114 secondi. Geek-Blog.it