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:

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

Daily Test with Code Example

Which tag is a block element?
<div> <img> <span>
<div>Web Programming and Development</div>
Which CSS code displays the text underlined?
font-style: italic; text-decoration: underline; font-weight: 500;
h2 {
  text-decoration: underline;
Click on the JavaScript function that can access other function after a specified time.
insertBefore() setTimeout() querySelector()
function someFunction() { alert(""); }
setTimeout("someFunction()", 2000);
Click on the instruction that returns the number of items of a multidimensional array in PHP.
count($array) count($array, 1) strlen()
$food = array("fruits" => array("banana", "apple"), "veggie" => array("collard", "pea"));
$nr_food = count($food, 1);
echo $nr_food;       // 6
Get the Height and Width of web Page and browser Window

Last accessed pages

  1. Register and show online users and visitors (14143)
  2. Butterfly Kyodai (10736)
  3. Splat Operator in PHP (1247)
  4. Logic Perspicacity Games (4065)
  5. Integer and Float value in Select with PDO from string to numeric (2921)

Top accessed pages

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (49507)
  2. Read Excel file data in PHP - PhpExcelReader (37896)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (36877)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (33252)
  5. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (30620)