【Front end tutorial】JS BOM

js bom browser object model

BOM (Browser Object Model) browser object model, JS accesses some properties of the browser through the BOM

But the BOM relies on the browser to exist

What is included in the BOM?

window

The core concept of BOM is window. The global variables of JS in the browser are all under window, including:

document

Document object, DOM interface exists under document

history

Represents some access records of the browser, it is a read-only

1
2
// jump to previous page
history.back()

location

Represents information such as browser address

1
2
3
4
5
// get the url address of the current page
location.href

// Get the current domain name
location.hostname

navigator

Represents the browser’s own properties, version, manufacturer, etc.

1
2
// common, get browser information
navigator.userAgent

You don’t need to memorize these things to learn these things. When you use them often, you will remember them naturally.

Persist in original technology sharing, your support will encourage me to continue to create!