Browser Object Model
The Browser Object Model (BOM) is a collection of JavaScript objects provided by web browsers that allow developers to interact with and manipulate various aspects of the browser window and the user's environment. Unlike the Document Object Model (DOM), which deals with the structure and content of the web page, the BOM focuses on the browser itself. The BOM provides objects and methods to control browser features such as windows, frames, history, location, and more.
Some common objects and properties in the Browser Object Model include:
- window: Represents the browser window and serves as the global object in client-side JavaScript.
- document: Represents the web page being displayed and provides access to its content through the DOM.
- navigator: Contains information about the user's browser and operating system.
- location: Represents the URL of the current web page and provides methods to manipulate it.
- history: Represents the user's browsing history and allows navigation back and forth.
- screen: Provides information about the user's screen dimensions and resolution.
Global Object
The browser's window is indeed represented by a global object known as the window object. The window object is a fundamental component of web browsers and is consistently supported by major browsers. It encapsulates various global JavaScript objects, and any function, object, or variable declared in JavaScript becomes inherently associated with the window object. This design effectively makes these elements accessible as members of the Window object, providing a unified and accessible environment for managing and interacting with browser-related functionalities. Few examples of window object properties and methods as follows:
Document element
The Document element, serving as the root of DOM elements, is an integral component within the Browser Object Model (BOM) hierarchy. This Document object symbolizes the web page that is presented in the browser. All constituents of a web page, encompassing HTML tags, reside within this Document object. Due to its major importance within the BOM, it possesses a distinct object model referred to as the Document Object Model (DOM).
Unlike the standardized and well-defined Document Object Model, the BOM lacks a uniform implementation or strict specification, affording browser vendors the freedom to implement it according to their preferences. Additionally, all global JavaScript objects, functions, and variables inherently align with the Window object, forming part of its membership. Notably, JavaScript often permits the omission of the window reference when accessing numerous elements, contributing to a more concise syntax. Examples of Global objects as follows:
The example shown in the above two statements means the same.
BOM exampleDevelopers can use the BOM to perform tasks such as opening new browser windows, redirecting to different URLs, manipulating the browser's history, displaying alerts and prompts, and interacting with the user's device and environment.
Conclusion
It's important to note that the BOM is not standardized by any official specification like the DOM is. This means that different browsers may provide slightly different BOM features and methods, leading to inconsistencies in behavior across browsers.
- JavaScript Interview Questions (Part2)
- JavaScript Interview Questions (Part3)
- Is JavaScript a true OOP language?
- Advantages and Disadvantages of JavaScript
- Difference Between JavaScript and ECMAScript?
- What is noscript tag?
- Escaping Special Characters in JavaScript
- What is undefined x 1 in JavaScript?
- Logical operators in JavaScript
- Difference between '=', '==' and '===' operators in JS
- How to loop through objects in JavaScript?
- How to write html code dynamically using JavaScript?
- How to add html elements dynamically with JavaScript?
- How to load another html page from javascript?
- What Is The Disadvantages Using InnerHTML In JavaScript?
- How to detect the OS on the client machine in JavaScript?
- Difference between window, document, and screen in Javascript?
- Difference between the substr() and substring() in JavaScript?
- How to replace all occurrences of a string in JavaScript?
- Test a string as a literal and as an object in JavaScript
- What is Associative Array in JavaScript
- What is an anonymous function in JavaScript?
- What is the use of 'bind' method in JavaScript?
- Pure functions Vs. Impure functions in javascript
- Is Javascript a Functional Programming Language?
- What's the Difference Between Class and Prototypal Inheritance?
- Javascript, Pass by Value or Pass by Reference?
- How to prevent modification of an object in Javascript?
- What is 'this' keyword in JavaScript?
- How Does Function Hoisting Work in JavaScript?
- What do mean by NULL in Javascript?
- What does the delete operator do in JavaScript?
- What is the Infinity property used for in Javascript?
- Event bubbling and Event Capturing in JavScript?
- What is "strict mode" and how is it used in JavaScript?
- What is the difference between call and apply in JavaScript
- Entire content of a JavaScript source file in a function block?
- What is an immediately-invoked function expression?
- What is escape & unescape String functions in JavaScript?
- Instanceof operator in JavaScript
- What Are RESTful (REpresentational State Transfer)Web Services?
- What is Unobtrusive JavaScript & Why it's Important?
- What Does JavaScript Void(0) Mean?
- What are JavaScript Cookies?
- Difference between Client side JavaScript and Server side JavaScript
- TypeError: document.getelementbyid(...) is null
- Uncaught TypeError: Cannot read property of undefined In JavaScript
- Null and Undefined in JavaScript