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 adds an image in web page?
<div> <img> <span>
<img src="" width="191" height="63" alt="Courses-Web" />
Which of these CSS codes displays the text oblique?
font-style: italic; text-decoration: underline; font-weight: 500;
#id {
  font-style: italic;
Click on the jQuery function used to hide with animation a HTML element.
click() hide() show()
$(document).ready(function() {
  $(".a_class").click(function(){ $(this).hide("slow"); });
Click on the correctly defined function in PHP.
fname function() {} function fname() {} function $fname() {};
function fname($a, $b) {
  echo $a * $b;
Get the Height and Width of web Page and browser Window

Last accessed pages

  1. Get and Check variable type in JavaScript (590)
  2. Dynamic variables in JavaScript (7620)
  3. Multidimensional arrays and array functions (6248)
  4. Integer and Float value in Select with PDO from string to numeric (5520)
  5. Contact page - CoursesWeb (8526)

Popular pages this month

  1. Making DIV Contents Scroll Horizontally, with multiple Div`s inside (2459)
  2. Contact page - CoursesWeb (2375)
  3. Tabs effect with CSS (2365)
  4. Insert, Select and Update NULL value in MySQL (1353)
  5. PHP getElementById and getElementsByTagName (931)