JS: Browser Window Object, DOM
- Browser's window object. This is the
- Document Object. This is the object
Browser's Window Object (Browser Object Model. BOM)
window object is the root global object.
Everything is a property of the
window object, including:
- HTML page elements.
- DOM objects.
- Browser's functions and objects.
In browser console, type
window to view this object's properties. [see JS: How to Use Browser Console]
window object has important properties. For example:
window.open("http://example.com/")[see DOM: Open URL window.open]
window.setInterval(…)[see JS: SVG Clock]
window.encodeURI(…)[see Encode/Decode URL tutorial]
window.innerWidth. [see JS: Find Window Size]
window.localStorage[see JS: Web Storage Tutorial]
window.location[see JS: 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
The window object and its properties and their behavior is called Browser Object Model (BOM).
Browser's Document Object (Document Object Model. DOM)
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. [see DOM: Create/Insert HTML Element]
- Remove element. [see DOM: Remove HTML Element]
- Change element's attributes. (such as class, id, name, width, etc.) [see DOM: Set Node Attribute Value]
- Change element's content. [see DOM: Change Element's Content]
- Change element's CSS style. [see DOM: Change CSS]
[see DOM: Basic DOM Methods]
If you have a question, put $5 at patreon and message me.