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

Script code

- Just add the following HTML /CSS /JS code in the pages of your website.

border:2px solid #0000be;

<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.

//if JavaScript enabled, it hides #jsad_notify
var jsad_notify = document.querySelector('#jsad_notify'); ='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';
 //if Ads blocked it shows the message, else it removes the #jsad_notify
 if(test_adb.offsetHeight ===0) ='block';
 else jsad_notify.outerHTML ='';

 document.body.removeChild(test_adb); //removes test_adb elm.
}, 700);

To change the position and design of the message, edit the CSS properties of the #jsad_notify element.

Daily Test with Code Example

Which attribute indicates that an input field must be filled out before submitting?
required="required" autofocus="autofocus" placeholder="text"
<input type="text" name="name1" required="required" />
Which CSS method increases or decreases the size of the HTML element (including its content)?
translate() scale() skew()
#some_id:hover {
  transform: scale(2, 1.5);
  -ms-transform: scale(2, 1.5);    /* IE 9 */
  -moz-transform: scale(2, 1.5);   /* Firefox */
Click on the Date object method that returns the day of the month.
setDate() getMonth() getDate()
var rightnow = new Date();
var day = rightnow.getDate();
Which function is used to upload a file on server?
is_file() move_uploaded_file() fopen()
if(move_uploaded_file($_FILES["field_name"]["tmp_name"], "dir/file_name")) {
  echo "The file succesfully uploaded";
Show a message if JavaScript disabled or Ad-Blocker

Last accessed pages

  1. Display data from PHP Array, or MySQL in HTML table (14212)
  2. Create simple Website with PHP (20530)
  3. PHP-MySQL Tutorials (2840)
  4. Read Excel file data in PHP - PhpExcelReader (60997)
  5. Adding data from HTML Table Rows in Form fields (5647)

Popular pages this month

  1. Insert, Select and Update NULL value in MySQL (409)
  2. Read Excel file data in PHP - PhpExcelReader (329)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (254)
  4. PHP getElementById and getElementsByTagName (205)
  5. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (196)