01. The Browser Object Model

JavaScript's power and flexibility comes from its ability to access and manipulate objects that are native to the browser environment.

The collection of these objects is known as the Browser Object Model (BOM). The BOM is a tree-like hierarchy of objects, each with useful access properties and methods. Essentially, this object allows you to talk with your user's browser.

Functions include querying the the browser window size, the main heading of the page, a pointer to the last page in a user's history and more!

Elements of the Browser Object Model

The BOM's root is the window object, which displays properties of the current open window or tab. It has several children, most of which we'll cover in this section.

JavaScript BOM tree

Here is a brief description of each element on the tree.

document
Contains all HTML elements of the current page.
frames
Any frames embedded within the current page.
history
Contains a stack of sites visited in the current session.
location
Stores URL of the current page.
navigator
Stores information about the browser being used, and the OS used by the browser.
screen
Display properties of the user's computer or device.

Because the document element has much to cover, it deserves its own section; we'll cover the other elements here, starting with the window object.

Build modern and responsive webpages

High Performance Web Sites

Build modern and responsive webpages Try Front-end

Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web.

$ Check price
29.9929.99Amazon 4.5 logo(63+ reviews)

More Front-end resources

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Ad