Javascript Course

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 HTML5 tag is indicated to be used as container for menu with navigation links in Web site?
<section> <nav> <article>
 <li><a href="" title="CSS Course">CSS Course</a></li>
 <li><a href="" title="Flash Games">Flash Games</a></li>
Which CSS property shifts an item horizontally to the left or right of where it was?
text-align clear float
.some_class {
  width: 30%;
  float: left;
Click on the Math object method which returns x, rounded downwards to the nearest integer.
Math.ceil(x) Math.abs(x) Math.floor(x)
var num = 12.34567;
num = Math.floor(num);
alert(num);       // 12
Indicate the PHP function which returns the number of characters in string.
mb_strlen() count() stristr()
$str = "string with utf-8 chars åèö";
$nrchr = mb_strlen($str);
echo $nrchr;        // 30
Show a message if JavaScript disabled or Ad-Blocker

Last accessed pages

  1. OOP - Constants, Static Properties and Methods (6074)
  2. SHA256 Encrypt hash in JavaScript (18166)
  3. While and Do While (2941)
  4. Simple arithmetic calculator in PHP (1301)
  5. Objects in 3D Space (1515)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (520)
  2. PHP Unzipper - Extract Zip, Rar Archives (423)
  3. SHA256 Encrypt hash in JavaScript (403)
  4. Read Excel file data in PHP - PhpExcelReader (360)
  5. Create simple Website with PHP (332)