03. Other BOM elements history, location, navigator, screen

There are a handful of other Browser Object Models that we will briefly go over here.

Screen

The window.screen object obtains information about the user's screen.

availHeight, availWidth
Width and height of the available screen (excluding taskbars).
height, width
Width and height of the available screen (with taskbars).
colorDepth
Number representing the bit depth of the color palette on user's screen.

Navigator

The window.navigator object is used to query a number of elements about the visitor's browser and environment.

language
Determine language of browser.
appName
Check name of browser.
geolocation
Returns geolocation object used to locate user's position.
onLine
Determines if user is online.
platform
Which platform user is using (OS X, Windows, Linux).
cookieEnabled
Determines whether cookies are enabled.
javaEnabled()
Check if user's Java is enabled.

Location

The window.location object provides information about the current URL.

hash
Returns anchor part of a URL.
host
Returns hostname and port number of URL.
pathname, port
Returns path or nort number of URL.
hostname
Returns hostname of a URL.
origin
Returns protocol, hostname and portname of a URL.
assign()
Loads new document.
reload()
Reload current document.
replace()
Replace current document.

History

The window.history gives you information regarding the user's history. Due to security concerns, we can't directly access which URL's our users have visited, but we may find other parameters.

length
Return the length of the user's history.
back(), forward()
Move the user forward or back a page.
go()
Loads specific URL from history list.

Build modern and responsive webpages

JavaScript & JQuery

Build modern and responsive webpages Try Front-end

This book was written for anyone who wants to use JavaScript to make their websites a little more interesting, engaging, interactive, or usable. In particular, it is aimed at people who do not have a degree in computer science (well, not yet anyway).

$ Check price
39.9939.99Amazon 4.5 logo(385+ 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