Javascript Detect Adblock

Last updated on
Subscribe to Internet Tips and Tools Feed

Do you want to stop Adblock from blocking your Google Adsense Ads and hurting your revenue? Here is a simple javascript script that detects if Adblock or another Ad blocker is blocking your Google Adsense ads or ads from another ad network. It will then display your own local ads. You could put a local image with a link to an Amazon product or your could politely ask your users to turn off the adblocker or whatever you want to do.

Features

  • Detect Adblock or other ad blocker
  • Display your own local ad
  • Customize to work with other ad networks
dlc_b

Download

Downloaded 0 times.
Please make a donation to help with server costs and other expenses.

How To Use

After downloading edit the following variables in the javascript file:

	var your_class = "sra_div"; // Put the class name of the div elements that contain your local ads here
	var other_class = "adsbygoogle"; // Put the class name of the ad network elements here. Use "adsbygoogle" for Adsense

Add the following code to you html page:

<script type="text/javascript" src="block_detect.js">
</script>

History

4/17/2018 - Version 1.2b - Removing adsbygoogle in version 1.2 caused the script to display your_ads even though google ads were loading. Fixed by putting || (typeof adsbygoogle != "undefined" && typeof adsbygoogle.loaded != "undefined")

4/16/2018 - Version 1.2 - Removed || (adsbygoogle && adsbygoogle.loaded) to prevent error: Uncaught ReferenceError: adsbygoogle is not defined on line 27.

2/21/2018 - Verison 1.1 - Previously the div element that contains the ad that was being blocked was not being set to display="none". In a few mobile browsers this caused a blank space to be visible. Fixed by using display="none".

2/19/2018 - Version 1.0 - Javascript Detect Adblock created

Last updated on April 17, 2018
Created on February 19, 2018

Back to www.seabreezecomputers.com
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 0 comments.

Displaying first 50 comments.