Tuple Logo
browser-object-model-bom

SHARE

Browser Object Model (BOM)

What is the Browser Object Model (BOM)?

The Browser Object Model (BOM) is a collection of objects provided by the browser that JavaScript can use to interact with the browser environment. Unlike the Document Object Model (DOM), which focuses on the structure and content of a webpage, the BOM deals with everything outside the document; such as the browser window, navigation history, and address bar.

BOM is not officially standardized by an organization like the W3C (which defines the DOM), but it is widely supported across modern browsers. While implementation details may vary slightly, the core objects and functionality are generally consistent.

The difference between BOM and DOM

Although BOM and DOM are often used together, they serve different purposes:

FeatureDOMBOM
What it describesThe content and structure of a webpageThe browser environment outside the page
Main objectdocumentwindow
StandardizedYes (W3C)No (browser-defined)
Examplesdocument.getElementById()window.open()

Think of it this way: the DOM lets you work with the content, while the BOM provides you with access to the environment in which that content runs.

How the BOM works in the browser

In every browser, the top-level object in the JavaScript environment is the window object. This object contains several sub-objects like navigator, location, history, screen, and functions like alert() or setTimeout(). With window, you can control nearly every aspect of the browser interface through JavaScript.

Here’s a basic representation of the BOM structure:

window
├── navigator
├── location
├── history
├── screen
├── alert()
├── setTimeout()
└── ...

Because window is the global object in browsers, you don’t need to reference it explicitly. For example, alert("Hi") works the same as window.alert("Hi").

Why the Browser Object Model is important

The Browser Object Model plays a crucial role in enabling interaction between a web page and the browser it runs in. Without BOM, JavaScript would only be able to modify the content of the page, not interact with the surrounding environment.

Access to browser functionality

Through the BOM, you gain access to features that go beyond the structure of the webpage. For example, you can:

These capabilities are essential for creating responsive and user-friendly websites.

Interaction with the user’s environment

BOM also lets you retrieve information about the user’s browser environment. This includes:

This kind of data helps developers tailor the experience to fit the user’s device or settings.

Supporting dynamic web applications

In modern web applications, BOM plays a supportive but important role. For instance, it allows you to:

Even though many frameworks abstract away some of these browser interactions, BOM remains relevant when:

The core of the BOM: the window object

The window object is the foundation of the Browser Object Model. Everything within the BOM exists either directly or indirectly under window. In a browser environment, window is the global object, meaning all global variables and functions are attached to it.

Understanding the window object

When you run a JavaScript file in the browser, it executes within the context of the window object. All BOM methods and properties are part of it. In most cases, you don’t need to explicitly write window, as it is implied by default.

For example:

alert("Hello!");

is the same as:

window.alert("Hello!");

This applies to other functions as well, such as setTimeout, setInterval, or accessing other BOM-related objects like window.location or window.history.

Relationship with other objects

The window object acts as a container for several sub-objects and functions. These sub-objects allow you to interact with different parts of the browser:

You can consider the window object to be a gateway to everything the browser provides, covering both page-level functionality (via the DOM) and browser-level control (via the BOM).

Example: using window.alert()

function greetUser() {
  window.alert("Welcome to our website!");
}

In this example, the greetUser() function displays a popup using window.alert(). This method pauses script execution until the user clicks OK, useful for simple notifications or warnings.

Key objects within the BOM

The window object is the foundation of the Browser Object Model, but its true power lies in the various sub-objects it contains. These objects provide you with access to specific browser functionalities.

location object

The location object holds information about the current URL and allows you to redirect the browser to a different page.

Examples:

console.log(window.location.href); // Full URL
window.location.href = "https://example.com"; // Redirect to another site

Other useful properties include:

navigator object

The navigator object provides details about the browser and some aspects of the user's device.

Examples:

console.log(navigator.userAgent); // Browser and platform info
console.log(navigator.language);  // User’s preferred language

Common use cases include:

screen object

The screen object returns information about the user's physical screen, such as its width, height, and color depth. It can be useful for customizing layouts or triggering fullscreen experiences.

Example:

console.log(screen.width);  // Screen width in pixels
console.log(screen.height); // Screen height in pixels

Although CSS media queries are often preferred for responsive design, the screen object still has its place in applications like games or fullscreen video environments.

history object

The history object lets you interact with the browser’s session history. It allows simple navigation back and forth between previously visited pages.

Examples:

window.history.back();    // Go back to the previous page
window.history.forward(); // Go forward if available

Note: For privacy and security reasons, you can't view or edit the full browsing history directly.

Practical uses of the BOM

While the Browser Object Model typically operates behind the scenes, it plays a key role in enhancing interactivity and functionality on websites. Below are some common real-world uses of the BOM in modern web development.

Opening pop-ups with window.open()

With window.open(), you can open a new browser window or tab. It’s often used for external links, login dialogs, or print views.

Example:

window.open("https://example.com", "_blank");

Note: Most browsers block pop-ups unless triggered by a direct user action, like a click. Use this feature sparingly and only when necessary.

Reloading pages automatically

The BOM allows you to reload the current page using location.reload():

window.location.reload();

This can be useful when the page content needs to be refreshed after a certain action, such as submitting a form or handling an error.

Personalizing the user experience

You can use the BOM to tailor the experience based on the user’s environment. For example:

Example:

if (navigator.language.startsWith("en")) {
  alert("Welcome to the English version of our site!");
}

Managing navigation and history

With the history object, you can control browser navigation without reloading the entire page. This is especially useful in single-page applications (SPAs) or when offering simple back-navigation.

window.history.back(); // Go back one step in history

You can also update the URL dynamically without reloading:

window.history.pushState({}, '', '/new-path');

This approach is typically used in frameworks like React or Vue to manage routing on the client side.

Limitations and considerations

While the Browser Object Model (BOM) offers many useful capabilities, there are also important limitations and considerations to keep in mind. Especially in modern web development, where security, usability, and compatibility are key, it's essential to understand the potential downsides of using BOM features.

Security risks

Some BOM features, like window.open() and window.alert(), can be misused or perceived as intrusive. Browsers have built-in security mechanisms to protect users:

Always use BOM features responsibly and avoid annoying or invasive behavior.

Browser compatibility

Since BOM is not officially standardized, minor differences may exist between browsers. Modern browsers like Chrome, Firefox, Safari, and Edge support most BOM features consistently, but older or lesser-known browsers may behave differently.

Tip: Always check compatibility using tools like MDN Web Docs or Can I use.

BOM in modern JavaScript frameworks

In modern frameworks (such as React, Vue, or Angular), direct usage of BOM is often limited to specific cases:

Frameworks typically provide their methods for things like routing or state management. Still, understanding BOM remains valuable for when you need to interact directly with the browser outside the framework's ecosystem.

The role of the BOM in modern web development

The Browser Object Model (BOM) remains a relevant part of web development, even in an age where frameworks and libraries offer increasing levels of abstraction. The BOM acts as the bridge between the web page and the browser environment, providing access to functions like navigation, pop-ups, screen information, and history control.

While its use is often limited to specific cases in modern projects, it’s still valuable to understand how the BOM works. This knowledge is useful not only for direct implementation, but also for debugging, understanding browser behavior, or maintaining legacy code.

In summary:

A solid understanding of the Browser Object Model equips developers to build complete, functional, and user-friendly web applications.

Frequently Asked Questions
What is the Browser Object Model used for?

The Browser Object Model is used to access browser-specific functionality with JavaScript, such as opening windows, navigating to other pages, getting screen details, and retrieving user-related data.


What is DOM and BOM?

DOM (Document Object Model) represents the structure of the HTML page. BOM (Browser Object Model) allows interaction with the browser environment, like the location bar, screen size, and browsing history.


What is object model in web technology?

An object model in web technology is a programmable structure that represents parts of a system. In web development, the DOM models the page content, while the BOM models the browser environment.


What is the Browser Object Model history?

The BOM emerged in the early days of the web, when browsers like Netscape introduced additional objects to give developers more control over the browser window. Although it was never officially standardized, it became a core part of client-side JavaScript.


Articles you might enjoy

Piqued your interest?

We'd love to tell you more.

Contact us
Tuple Logo
Veenendaal (HQ)
De Smalle Zijde 3-05, 3903 LL Veenendaal
info@tuple.nl‭+31 318 24 01 64‬
Quick Links
Customer Stories