The code presented in this page can be used to detect if the visitor has an Ad-Blocker that blocks Ads, and to display a friendly message to visitor when the JavaScript is disabled or Ads are blocked.
The script was tested with Adblock Plus.

- Just add the following HTML /CSS /JS code in the pages of your website.
<div id='jsad_notify'>
Parts of this site works with JavaScript enabled; and without AdBlock.<br>
Please consider supporting us by disabling your Ad-Blocker on this website.
</div>

<style>
#jsad_notify{
background:#f8f800;
border:2px solid #0000be;
color:#ee0000;
font-size:20px;
font-weight:700;
margin:0;
padding:2px;
position:fixed;
top:40px;left:1%;right:1%;
text-align:center;
max-width:98vw;
}
</style>

<script>
// <![CDATA[
//if JavaScript enabled, it hides #jsad_notify
var jsad_notify = document.querySelector('#jsad_notify');
jsad_notify.style.display ='none';

//adds a child-element in page which usually is blocked by Ad-Blocker
var test_adb = document.createElement('div');
test_adb.innerHTML ='&nbsp;';
test_adb.className ='adsbox';
document.body.appendChild(test_adb);
window.setTimeout(function(){
 //if Ads blocked it shows the message, else it removes the #jsad_notify
 if(test_adb.offsetHeight ===0) jsad_notify.style.display ='block';
 else jsad_notify.outerHTML ='';

 document.body.removeChild(test_adb); //removes test_adb elm.
}, 700);
// ]]>
</script>
- To change the position and design of the message, edit the CSS properties of the #jsad_notify element.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag create a highlighted bolded text?
<q> <strong> <em>
<p>Address: <strong>http://CoursesWeb.net/</strong> - Tutorials.</p>
Which of these CSS codes displays the text bolded?
text-size: 18px; font-style: italic; font-weight: 800;
#id {
  font-weight: 800;
}
What JavaScript function can be used to call another function multiple times, to a specified time interval?
setInterval() setTimeout() push()
function someFunction() { alert("CoursesWeb.net"); }
setInterval("someFunction()", 2000);
Click on the correctly defined variable in PHP.
var vname = 8; $vname = 8; $vname == 8;
$vname = 8;
echo $vname;
Show a message if JavaScript disabled or Ad-Blocker

Last accessed pages

  1. The Mastery of Love (3341)
  2. Multiple Select Dropdown List with JavaScript (7841)
  3. Ajax-PHP File Manager (4736)
  4. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (70654)
  5. Add, Change, and Remove Attributes with jQuery (35782)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (1347)
  2. Qwop (670)
  3. Theme Hotel (590)
  4. Read Excel file data in PHP - PhpExcelReader (544)
  5. Register and show online users and visitors (493)