JavaScript TutorialDatatypes in JavaScriptEvaluating JavaScriptFunctional JavaScriptJavaScript .postMessage() and MessageEventJavaScript AJAXJavaScript Anti-patternsJavaScript Arithmetic (Math)JavaScript ArraysJavaScript Arrow FunctionsJavaScript Async functions (async/await)JavaScript Async IteratorsJavaScript Automatic Semicolon Insertion - ASIJavaScript Battery Status APIJavaScript Behavioral Design PatternsJavaScript Binary DataJavaScript Bitwise operatorsJavaScript Bitwise Operators - Real World Examples (snippets)JavaScript BOM (Browser Object Model)JavaScript Built-in ConstantsJavaScript CallbacksJavaScript ClassesJavaScript CommentsJavaScript Comparison OperationsJavaScript ConditionsJavaScript ConsoleJavaScript Constructor functionsJavaScript Context (this)JavaScript CookiesJavaScript Creational Design PatternsJavaScript Custom ElementsJavaScript Data attributesJavaScript Data ManipulationJavaScript DateJavaScript Date ComparisonJavaScript DebuggingJavaScript Declarations and AssignmentsJavaScript Destructuring assignmentJavaScript Detecting browserJavaScript EnumerationsJavaScript Error HandlingJavaScript Escape SequencesJavaScript EventsJavaScript execCommand and contenteditableJavaScript FetchJavaScript File API, Blobs and FileReadersJavaScript Fluent APIJavaScript FunctionsJavaScript GeneratorsJavaScript GeolocationJavaScript Global error handling in browsersJavaScript HistoryJavaScript How to make iterator usable inside async callback functionJavaScript IndexedDBJavaScript InheritanceJavaScript Intervals and TimeoutsJavaScript JSONJavaScript Linters - Ensuring code qualityJavaScript LocalizationJavaScript LoopsJavaScript MapJavaScript Memory efficiencyJavaScript Method ChainingJavaScript Modals - PromptsJavaScript Modularization TechniquesJavaScript ModulesJavaScript NamespacingJavaScript Navigator ObjectJavaScript Notifications APIJavaScript ObjectsJavaScript Performance TipsJavaScript PromisesJavaScript Prototypes, objectsJavaScript ProxyJavaScript Regular expressionsJavaScript requestAnimationFrameJavaScript Reserved KeywordsJavaScript Same Origin Policy & Cross-Origin CommunicationJavaScript ScopeJavaScript ScreenJavaScript Security issuesJavaScript Selection APIJavaScript Server-sent eventsJavaScript SetJavaScript Setters and GettersJavaScript Strict modeJavaScript StringsJavaScript SymbolsJavaScript Tail Call OptimizationJavaScript Template Literals

JavaScript BOM (Browser Object Model)

From WikiOD

Remarks[edit | edit source]

For more information on the Window object, please visit MDN.

The window.stop() method is not supported in Internet Explorer.

Introduction[edit | edit source]

The BOM (Browser Object Model) contains objects that represent the current browser window and components; objects that model things like history, device's screen, etc

The topmost object in BOM is the window object, which represents the current browser window or tab. BOM_(Browser_Object_Model)

  • Document: represents current web page.
  • History: represents pages in browser history.
  • Location: represents URL of current page.
  • Navigator: represents information about browser.
  • Screen: represents device's display information.

Window Object Methods[edit | edit source]

The most important object in the Browser Object Model is the window object. It helps in accessing information about the browser and its components. To access these features, it has various methods and properties.

Method Description
window.alert() Creates dialog box with message and an OK button
window.blur() Remove focus from window
window.close() Closes a browser window
window.confirm() Creates dialog box with message, an OK button and a cancel button
window.getComputedStyle() Get CSS styles applied to an element
window.moveTo(x,y) Move a window's left and top edge to supplied coordinates Opens new browser window with URL specified as parameter
window.print() Tells browser that user wants to print contents of current page
window.prompt() Creates dialog box for retrieving user input
window.scrollBy() Scrolls the document by the specified number of pixels
window.scrollTo() Scrolls the document to the specified coordinates
window.setInterval() Do something repeatedly at specified intervals
window.setTimeout() Do something after a specified amount of time
window.stop() Stop window from loading

Window Object Properties[edit | edit source]

The Window Object contains the following properties.

Property Description
window.closed Whether the window has been closed
window.length Number of <iframe> elements in window Gets or sets the name of the window
window.innerHeight Height of window
window.innerWidth Width of window
window.screenX X-coordinate of pointer, relative to top left corner of screen
window.screenY Y-coordinate of pointer, relative to top left corner of screen
window.location Current URL of window object (or local file path)
window.history Reference to history object for browser window or tab.
window.screen Reference to screen object
window.pageXOffset Distance document has been scrolled horizontally
window.pageYOffset Distance document has been scrolled vertically