Javascript Course

Page sizes

If you want to get the total Height and Width of the page content in JavaScript, you can use this code:
// gets the total height of the page content
var page_height = document.body.offsetHeight ? document.body.offsetHeight : document.height;

// gets the total width of the page content
var page_width = document.body.offsetWidth ? document.body.offsetWidth : document.width;

// Test
alert('Height: '+ page_height +' px \nWidth: '+ page_width +' px');
- Example:
Click:

Window sizes

This function, getWindowSize(), can be used to get the Height and Width of the browser window, in pixels:
// Returns an Array with the 'height' and 'width' of the browser window, in pixels
function getWindowSize() {
 // from:  https://coursesweb.net/javascript/
  var win_size = new Array;
  if (self.innerHeight) {
    win_size['height'] = self.innerHeight;
    win_size['width'] = self.innerWidth;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    win_size['height'] = document.documentElement.clientHeight;
    win_size['width'] = document.documentElement.Width;
  } else if (document.body) {
    win_size['height'] = document.body.clientHeight;
    win_size['width'] = document.body.clientWidth;
  }
  return win_size;
}

// Test: gets the array with the window sizes
var win_dim = getWindowSize();
alert('Height: '+ win_dim['height'] +' px \nWidth: '+ win_dim['width'] +' px');
- Example:
Click:

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
Get the Height and Width of web Page and browser Window

Last accessed pages

  1. The Mastery of Love (6764)
  2. SHA256 Encrypt hash in JavaScript (31200)
  3. Convert XML to JSON in PHP (12409)
  4. Select in MySQL, Output results in HTML Table (19325)
  5. The Four Agreements (1616)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (241)
  2. Read Excel file data in PHP - PhpExcelReader (84)
  3. The Four Agreements (73)
  4. PHP Unzipper - Extract Zip, Rar Archives (72)
  5. The Mastery of Love (61)
Chat
Chat or leave a message for the other users
Full screenInchide