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() {
  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)) {

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

Daily Test with Code Example

Which attribute can be used to add CSS styles directly in the HTML tag?
type style class
<div style="width: 80%; border: 3px solid #888888;">Content</div>
Which CSS transform method distorts the HTML element in a given angle (including its content)?
translate() scale() skew()
#some_id {
  transform: skew(20deg, 25deg);
  -ms-transform: skew(20deg, 25deg);   /* IE 9 */
  -webkit-transform: skew(20deg, 25deg);   /* Safari and Chrome */
Click on the function which converts a Date object to a string.
indexOf() toString() getDate()
var rightnow = new Date();
alert( rightnow.toString() );
Which function applies a callback function to the elements of the given array?
array_merge() array_search() array_map()
$arr = arra("abc", "<p>xyz</p>", "<em>PHP</em>");
// apply the strip_tags() function to delete HTML tags from each array item
$arr = array_map("strip_tags", $arr);
Detect when ScrollBar reaches the bottom of the page

Last accessed pages

  1. SHA1 Encrypt data in JavaScript (17716)
  2. Add and Remove HTML elements and Content with jQuery (27110)
  3. PHP getElementById and getElementsByTagName (38341)
  4. Insert, Select and Update NULL value in MySQL (51651)
  5. Display data from PHP Array, or MySQL in HTML table (19023)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (243)
  2. Register and show online users and visitors (151)
  3. Read Excel file data in PHP - PhpExcelReader (144)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (139)
  5. JavaScript Course - Free lessons (115)