when doing web dev, there are 3 kinds of objects you work with:
- Browser's window object. Represented by keyword
- Document Object. Represented by keyword
The Window Object
window object is
the Global Object.
are properties of the
In browser console, type
window to view this object's properties. [see How to Use Browser Console]
window object has critical properties.
Examples of important functions:
window.alert→ show a popup window.
window.setTimeout→ call a function after a given delay.
window.setInterval→ call a function periodically. [see SVG Clock]
window.encodeURI[see Encode/Decode URL tutorial]
window.innerWidth. [see Find Window Size]
window.localStorage[see Web Storage]
window.location[see Get URL (window.location)]
You don't need to prefix
window. to use its methods or properties. For example,
alert("3") is same as
The window object also has a property key
are the same as just
Browser Object Model
The window object and its properties and their behavior is sometimes called the Browser Object Model (aka BOM).
The Document Object (Document Object Model)
One of the most important property of
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:
- Insert element.
- Remove element.
- Change element's attributes. (such as class, id, name, etc.)
- Change element's content.
- Change element's CSS style.