How to detect ad block

Hy I need script for my site that detect that in user browser adblock is on r not and if it is on then it will redirect user to new page to say turn off adblock

Hi there @nalinnishantnn

I have removed your website URL as it is not necessary for your query and it looks like link dropping.

This is not something you can do with PHP AFAIK. You will need to use JavaSscript, I think. There is a solution here.

I have moved your post to the JS forum.

You can use this library: https://github.com/sitexw/BlockAdBlock

Then you can do:

if(typeof blockAdBlock === 'undefined') {
  window.location = whatever;
}

I’d consider the wisdom of this approach, however. I’d be inclined to leave any site that did this.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.