JS: Browser Window Object, Document Object Model
- Browser's window object. This is the
- Document Object. This is the object
Browser Window Object
window object is the global object. Anything you do with a browser, is done via the
In browser console, type
window to view this object's properties. [see JS: How to Use Browser Console]
window object. [see JS: var Name Scope]
window object has important properties. For example:
window.open("http://example.com/")[see JS: Open URL window.open(…)]
window.setTimeout(…)[see JS: Fade a Element]
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, because its a global object. For example,
alert("3") is same as
The window object also has a property key
window.window refers to itself.
all refer to
The window object and its system is called Browser Object Model (BOM).
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 HTML Element]
- Remove element. [see DOM: Remove HTML Element]
- Change element's attributes. (such as class, id, name, width, etc.) [see DOM: Set Element's Attribute Value]
- Change element's content. [see DOM: Change Element's Content]
- Change element's CSS style. [see JS: Change CSS]
[see DOM: Basic DOM Methods]
Web Scripting Overview Topic
Ask me question on patreon