Getting started with JavaScriptFunctionsArraysObjectsAJAXClassesArithmetic (Math)Comparison OperationsConditionsLoopsPromisesRegular expressionsDateError HandlingGeolocationCookiesIntervals and TimeoutsGeneratorsHistoryStrict modeCustom ElementsJSONBinary DataTemplate LiteralsWeb StorageFetchScopeModulesScreenInheritanceTimestampsDestructuring assignmentWorkersVariable coercion/conversionDebuggingNotifications APIBuilt-in ConstantsWebSocketsWeb Cryptography APIAsync functions (async/await)StringsConstructor functionsexecCommand and contenteditablePerformance TipsMapCreational Design PatternsrequestAnimationFrameReserved KeywordsMethod ChainingGlobal error handling in browsersUnary OperatorsFile API, Blobs and FileReadersCommentsConsoleTail Call OptimizationDetecting browserEnumerationsSymbolsLocalizationSelection APICallbacksSetDeclarations and AssignmentsFunctional JavaScriptModals - PromptsData attributesThe Event LoopBattery Status APIData ManipulationBitwise operatorsTranspilingBOM (Browser Object Model)Unit Testing JavascriptLinters - Ensuring code qualityAutomatic Semicolon Insertion - ASIIndexedDBAnti-patternsNavigator ObjectModularization TechniquesProxySame Origin Policy & Cross-Origin CommunicationArrow Functions.postMessage() and MessageEventWeakMapWeakSetEscape SequencesBehavioral Design PatternsServer-sent eventsAsync IteratorsNamespacingEvaluating JavaScriptMemory efficiencyDate ComparisonHow to make iterator usable inside async callback functionContext (this)Setters and GettersVibration APIPrototypes, objectsDatatypes in JavascriptBitwise Operators - Real World Examples (snippets)Fluent APITilde ~Security issuesUsing javascript to get/set CSS custom variablesJavaScript VariablesEvents

BOM (Browser Object Model)

Other topics

Remarks:

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

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

Introduction

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. enter image description here

  • 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

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.

MethodDescription
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
window.open()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

The Window Object contains the following properties.

PropertyDescription
window.closedWhether the window has been closed
window.lengthNumber of <iframe> elements in window
window.nameGets or sets the name of the window
window.innerHeightHeight of window
window.innerWidthWidth of window
window.screenXX-coordinate of pointer, relative to top left corner of screen
window.screenYY-coordinate of pointer, relative to top left corner of screen
window.locationCurrent URL of window object (or local file path)
window.historyReference to history object for browser window or tab.
window.screenReference to screen object
window.pageXOffsetDistance document has been scrolled horizontally
window.pageYOffsetDistance document has been scrolled vertically

Contributors

Topic Id: 3986

Example Ids: 13901,13902,16673

This site is not affiliated with any of the contributors.