The Browser Object Model (BOM) refers to all the JavaScript-accessible objects provided by the web browser (not the web page) that allow developers to interact with the browser itself — things like the window, the screen, the browser history, the location bar, and pop-ups.
Learn JavaScript from the comfort of your home
While the DOM is about the document (HTML), the BOM is about the browser environment.
| Feature | DOM | BOM |
|---|---|---|
| What it Represents | HTML document | Browser environment |
| Provided by | Browser | Browser |
| Examples | document, elements, nodes | window, navigator, location, history |
| Purpose | Manipulate page content | Interact with browser features |
window Object (The ROOT of BOM)The window object is the global object for JavaScript running in the browser.
Everything in the BOM hangs from window.
Examples:
console.log(window.innerWidth);
console.log(window.innerHeight); | Method | Description |
|---|---|
alert() | Displays popup alert |
confirm() | OK/Cancel popup |
prompt() | Input popup |
setTimeout() | Run function once after delay |
setInterval() | Run function repeatedly |
clearTimeout() | Stop timeout |
clearInterval() | Stop interval |
setTimeout(() => {
console.log("This runs after 3 seconds");
}, 3000); window.location Object — URL Information & NavigationControls and retrieves parts of the current browser URL.
| Property | Description |
|---|---|
location.href | Full URL |
location.hostname | Domain |
location.pathname | Page path |
location.search | Query string |
location.hash | Fragment (#) |
location.protocol | http: / https: |
| Method | Description |
|---|---|
location.assign() | Load a new page |
location.replace() | Replace current page (no back button) |
location.reload() | Refresh page |
console.log(location.href);
location.reload(); window.history Object — Browser NavigationAllows JavaScript to move forward/backward in the browsing history.
| Method | Description |
|---|---|
history.back() | Go to previous page |
history.forward() | Go to next page |
history.go(n) | Move n steps (-1, +1, etc.) |
history.go(-1); // Equivalent to back() window.screen Object — Device Screen InfoProvides information about the user’s screen.
| Property | Description |
|---|---|
screen.width | Screen width |
screen.height | Screen height |
screen.availWidth | Available width |
screen.availHeight | Available height |
console.log(screen.width, screen.height); window.navigator Object — Browser & Device MetadataGives information about the browser and environment.
| Property | Description |
|---|---|
navigator.userAgent | Browser/OS details |
navigator.language | User’s language |
navigator.onLine | Online/offline status |
navigator.geolocation | GPS access (requires permission) |
console.log(navigator.language);
console.log(navigator.onLine); navigator.geolocation.getCurrentPosition(pos => {
console.log(pos.coords.latitude, pos.coords.longitude);
}); open, close, moveTo, resizeTo)let popup = window.open("https://example.com", "_blank", "width=500,height=500"); popup.close(); setTimeout & setIntervalAlready part of window, but extremely important.
let i = 0;
let timer = setInterval(() => {
console.log("Tick: " + i++);
if (i === 5) clearInterval(timer);
}, 1000); You can access cookies using:
document.cookie = "username=John; expires=Fri, 31 Dec 2025 23:59:59 GMT";
console.log(document.cookie); | BOM Object | Purpose |
|---|---|
window | Root of everything |
location | URL navigation |
history | Forward/back navigation |
screen | Screen/device display info |
navigator | Browser/system info |
alert/prompt/confirm | Popup dialogs |
setTimeout/setInterval | Timers |
The BOM (Browser Object Model) is the set of JavaScript-accessible objects provided by the browser that let you interact with browser features such as navigation, history, screen, popups, timers, and browser metadata.
Latest tech news and coding tips.
Visual Studio Code (VS Code) is powerful out of the box, but its real strength…
1. What Is a Variable in JavaScript? A variable is a named container used to store data…
1. What Is a Queue? A Queue is a linear data structure that follows the principle: FIFO – First…
Angular is a full-featured frontend framework built by Google for creating large, maintainable, and high-performance web applications.…
What Is Responsive Web Design? Responsive Web Design (RWD) is an approach to building websites…
The Geolocation API allows a web application to access a user’s geographical location (latitude, longitude, and more), with…