Javascript Course

The JavaScript function presented in this page can be used to Detect when ScrollBar reaches the bottom of the page.
This function is useful when you want to execute some JavaScript code when the user scrolls till the bottom of page, for example to display another content, making an infinite scroll.
Here is the function, named whenScrlBottom(). It must be accessed by the "onscroll" event.
// function to detect when scroollbar reaches the bottom of page
var whenScrlBottom = function() {
  // https://coursesweb.net/javascript/
  var win_h = (self.innerHeight) ? self.innerHeight : document.body.clientHeight;    // gets window height

  // gets current vertical scrollbar position
  var scrl_pos = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

  // if scrollbar reaces to bottom
  if (document.body.scrollHeight <= (scrl_pos + win_h)) {
    alert('Bottom');
  }
}

// register event on scrollbar
window.onscroll = whenScrlBottom;

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
What attribute makes an option from <select> selected?
checked="checked" selected="selected" disabled="disabled"
<select name="a_name">
 <option value="val1">Option 1</option>
 <option value="val2" selected="selected">Option 2</option>
</select>
What CSS value allows to create color gradients for background?
contain repeat-x linear-gradient
#id {
  background: linear-gradient(top left, #1f1, #fff, #11f);
}
What statement creates an array in JavaScript?
[] {} new Object()
var arr = [1, "CoursesWeb.net", "MarPlo.net"];
alert(arr[2]);
Indicate the PHP function used to redirect to other page.
function() header() switch()
header("Location: http://coursesweb.net/");
exit;
Detect when ScrollBar reaches the bottom of the page

Last accessed pages

  1. PHP getElementById and getElementsByTagName (49170)
  2. Rectangle, Oval, Polygon - Star (3217)
  3. Tutorial Motion Presets (2518)
  4. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (137701)
  5. PHP Method Chaining (5351)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (14)
  2. SSEP - Site Search Engine PHP-Ajax (7)
  3. The Mastery of Love (4)
  4. Zen Flesh, Zen Bones (4)
  5. Read Excel file data in PHP - PhpExcelReader (4)