Search within TutorialsPark

Javascript BOM : Screen Object

To get information related to user's display and other screen properties

Javascript BOM : Screen Object

The Javascript screen object is get information about the user's display and number of color pixels available on it.

This object is has no programmatic use; it used purely to get information about the client's screen capabilities such as width , height , color-depth etc

The information is collected by site tracking tools that measure the capabilities of the client, but has no effect on the functionality

The best possible use of screen object's properties is to

Table : Properties and Methods of history Object

Name Description Returns
availHeight The height of the screen available for the purpose of displaying windows(excluding toolbars, menubars and so on) number
availWidth The width of the screen available for the purpose of displaying windows (excluding toolbars, menubars and so on) number
colorDepth To color depth of the screen number
height To height if the screen number.
width To width of the screen number

Javascript Screen Object: Getting Screen Information about the Window

To history object methods back() , forward() and go() are used to tell the browser to naviagte to specified URL in history.

The methods back() and forward() have the same effect as the browser's back and forward button.

The method go() is used to navigate to a URL in history relative to the current document.A positive value is used to move forward in the history while a negative value is used to move backwards.

Eg: the value "-2 " will move to a location two steps backward relative to current location, and value " 2 " moves two steps forward relative to current location.

Syntax: Javascript history Object: Navigating within browsing history

Example: Javascript Browser Object Model: Screen Object Width

Give it a TRY! » Note: Browser's history is stored in a stack.A Stack is a first-in first-out Data Structure

Javascript History Object: Inserting an Entry into browser History

The Javascript History.push method is used to add(i.e push) URL into browser history stack, under some constraints as follows:

1. The URL address must be from the same server name and port as the current document.

2. One way to add URLs is to make use of query string or hash fragment appended to the current document.

Example : Javascript Location object to navigate to external Pages

Give it a TRY! » Note: The query string is added to the current URL.

Javascript History Object : To Store Complex Data in Browser History

In the below demo, we have stored complex data in the browser history using pushstate() method.

Syntax: Javascript history Object using pushState Method

Give it a TRY! » Note: These system dialogs can be used to display information and ask for inputs from user.