How to detect Adblock on website

First Understand how ad blockers work..

When a browser requests a website address it downloads the corresponding HTML file which includes internal & external references to Javascript files, CSS stylesheets and images. If the browser has an ad blocker installed, it will compare the names of referenced scripts & files against a "block list" and if there are any matches those files will be ignored.

To fix this problem, here i am providing a small solution.

Create one "ads.js" file on th root and place the below code in that file.

var canAdsRunOnThisSite = true;

The following code add in between Head tags (<head>...</head>).

<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type = "text/javascript"> </script>
<%--Ad Block Code - JS - Start--%> 
<script src = "js/ads.js"> </script> 
    <script>
	$(window).load(function () {
		if (window.canAdsRunOnThisSite === undefined) {
			// adblocker detected, show message
			$("#notify").show();
			$('#top').animate({
				'height': $(window).height(),
				'position': 'fixed'
			});
			$('#adblocktext').fadeIn('1000');
			$('#alt').click(function () {
				$('#top').animate({
					'height': '50px',
				});
				$('#adblocktext').fadeOut('1000');
			});
		}  
	}); 
</script>
<%--Ad Block Code - JS - End--%>

In the Body content, at last add the following code. The below code i have added in this website.

<div id="notify" style="display:none;">
   <p id="adblocktext"> <br />
      I have detected that you are using AdBlock software. <br /> 
      This site is supported by advertisements to keep site free for everyone. <br /> 
      <span>Please add <a href="http://www.himasagar.com/">www.himasagar.com</a> to your 
      <br />
      ad blocking whitelist or disable your adblocking software.</span>  <br />
      <span id="sig">- Himasagar Kutikuppala </span> <br /><br />
      <span id="alt">Click here to close it. </span> <br />
   </p>
</div>


What is GST

GST (Goods and Service Tax) is a comprehensive tax on the supply of goods and services at each stage of any transaction. Read More

Income Tax Information

An income tax is a tax imposed by government on income earned by you. Income tax is a key source of funds that the government uses to fund its activities and serve the public. Read More

General Insurance Companies in India

General insurance is insurance for valuables other than our life and health. General insurance covers the insurer against damage, loss and theft of your valuables. Read More



Types of Bank Loans In India

Loan means lending money from one individual or entity to another. A loan has three components – principal or the borrowed amount, rate of interest and tenure or duration for which the loan is availed. Read More

List of Banks in India

The Reserve Bank of India is the central Bank that is fully owned by the Government of India. It is governed by a central board (headed by a Governor) appointed by the Central Government. Read More

List of Educational Institutions in India

The following list of comprehensive websites on higher education in India. These websites will provide detailed information on education system in India. Read More