Pergunta

I am trying to show which users have AdBlock and pass this information to Piwik but it seems to fail. It just shows like everyone got AdBlock enabled..

Here is the code I am using:

function _abpde() {
  if (document.getElementById("AdDiv")==null || document.getElementById("AdDiv").offsetHeight<=0) {
    _paq.push(['setCustomVariable',1,"AdBlock","Enabled","page"]);
  } else {
    _paq.push(['setCustomVariable',1,"AdBlock","Disabled","page"]);
  }
}
window.onload=_abpde();

And I am ussing the div:

<div class="AdDiv" id="AdDiv">&nbsp;asd</div>

Any ideas what I am doing wrong? Thanks!

PS: When I try to remove the document.getElementById("AdDiv")==null the whole script fails and it doesn't even count visits..

Foi útil?

Solução

window.onload=_abpde();

should be

window.onload=_abpde;

() makes the function execute immediately.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top