JS: Browser Window Object, DOM

By Xah Lee. Date: . Last updated: .

There are 3 kinds of objects you work with when using JavaScript for website:

Browser Window Object

The browser's window object is the root global object.

Everything is a property of the window object, including:

Google Chrome console window object 2014
Google Chrome console showing the window object

In browser console, type window to view this object's properties. [see JS: How to Use Browser Console]

The window object has important properties. For example:

You don't need to prefix window. to use its methods or properties. For example, alert("3") is same as window.alert("3")

The window object also has a property key "window", so window.window refers to itself. and window.window.window, window.window.window.window all refer to window.

The window object and its system is called Browser Object Model (BOM).

Document Object Model (DOM)

One of the most important property of window is window.document. This is the document object.

The document object represent the HTML/XML document in the browser window.

The document object contains methods to manipulate HTML elements and styles. This object system is called DOM (Document Object Model).

The DOM allows you to:

  1. Insert element. [see DOM: Create/Insert HTML Element]
  2. Remove element. [see DOM: Remove HTML Element]
  3. Change element's attributes. (such as class, id, name, width, etc.) [see DOM: Set Element's Attribute Value]
  4. Change element's content. [see DOM: Change Element's Content]
  5. Change element's CSS style. [see DOM: Change CSS]

[see DOM: Basic DOM Methods]

Web Scripting Overview

  1. Browser Window Object, DOM
  2. Intro to Event-Based Programing
  3. JavaScript Load Order
  4. What is Live Object
  5. NodeList vs HTMLCollection
  6. DOM: Whitespace Nodes
Liket it? I spend 2 years writing this tutorial. Help me spread it. Tell your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Ref
  5. DOM Scripting
  6. SVG
  7. Blog