DOM API - The "window" Object

This section provides a quick description of the 'window' object of the DOM API. A tutorial example is provided on retrieving properties from the current browser window.

The DOM API provided by the Web browser contains another useful object called "window", which has the following features:

To illustrate how to retrieve properties from the current window, I wrote this JavaScript tutorial example:

<!-- Window_Properties.html
   Copyright (c) 2008 All Rights Reserved.
<title>Window Properties</title>
<script type="text/javascript">
function getWindowProperties() {
   var text = "";
   text += "'document' property: "+ window.document.title+"\n";
   text += "'location' property: "+ window.location.pathname+"\n";
   text += "'history' property: "+ window.history.length+"\n";
   text += "'navigator' property: "+ window.navigator.appCodeName+"\n";
   text += "'outerWidth,outerHeight' property: "
      + window.outerWidth+","+ window.outerHeight+"\n";
   text += "'innerWidth,innerHeight' property: "
      + window.innerWidth+","+ window.innerHeight+"\n";
   text += "'screenX,screenY' property: "
      + window.screenX+","+ window.screenY+"\n";
   return text;
<script type="text/javascript">

Run this JavaScript example in Firefox browser, you will get something like this:

'document' property: Window Properties
'location' property: /C:/herong/Window_Properties.html
'history' property: 3
'navigator' property: Mozilla
'outerWidth,outerHeight' property: 1024,608
'innerWidth,innerHeight' property: 1006,485
'screenX,screenY' property: 72,73

This tutorial shows that:

See the next tutorial on how to create a new Window with the method.

Table of Contents

 About This Book

 Introduction to JavaScript

 ECMAScript Language Specification and JavaScript Dialects

 Data Types, Variables and Expressions

 Flow Control Statements

 Creating, Accessing, and Manipulating Arrays

 Defining and Calling Functions

Web Browser Supporting JavaScript

 JavaScript Support in Web Browsers

 Including JavaScript Codes with HTML "script" Tags

 type="text/javascript" or language="JavaScript"

 JavaScript Version Supported by Browsers

 Including 'script' Tags in String Literals

 Escaping 'script' Tags in String Literals

 Using HTML Entities to Protect HTML Tags

 Including JavaScript Codes as External Files

 DOM API - The "document" Object

DOM API - The "window" Object

 DOM API - The "" Method

 Event Listeners and Objects

 'javascript:' Pseudo-URL Addresses

 JavaScript Console in Google Chrome

 JavaScript Console in Mozilla Firefox

 JavaScript Console in Apple Safari

 JavaScript Console in IE (Internet Explorer)

 Server-Side and Client-Side Web Scripting

 Introduction to Objects

 Defining Your Own Object Types

 Inheritance of Properties and Methods through the Prototype Object Chain

 'jrunscript' - JavaScript Shell Command from JDK

 Using Functions as "Function" Objects

 Introduction to Built-in Object Types

 W3C's Document Object Model (DOM) Specifications

 AJAX (Asynchronous JavaScript And XML)


 Full Version in PDF/EPUB