DOM API - The "" Method

This section provides a quick description of the 'window' object of the DOM API. A tutorial example is provided on changing browser window size through the 'window' object.

The built-in object "window" also allows you to create a new browser window and returns a new window object. You can manipulate the new browser window through this object.

Here is JavaScript tutorial example that uses the method to create a new window:

<!-- Window_Object.html
   Copyright (c) 2008 All Rights Reserved.
<title>Window Object</title>
<script type="text/javascript">
var mySize = 0;
var myWin;

function openWin() {
   myWin ='','','left=300,top=100,width=600,height=600');

function changeSize() {
   if (mySize == 0 )
   else if (mySize == 1 )
   else if (mySize == 2 )
   else if (mySize == 3 )
   mySize = (mySize+1)%4;

function closeWin() {

<p>Click "Create Window" first start the test:</p>
  <input type="button" value="Create Window" onClick="openWin();"/>
  <input type="button" value="Resize Window" onClick="changeSize();"/>
  <input type="button" value="Close Window" onClick="closeWin();"/>

Run this JavaScript example in a Web browser and follow these steps to test this tutorial:

For more tutorial examples on the "window" object, see the DOM API chapters in this book.

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