History length Property

Get the number of URLs in the history list

Definition and Usage

The length property returns the number of URLs in the history list of the current browser window.

The property returns at least 1, because the list includes the current page.

This property is useful to find out how many pages the user has visited in the current browsing session.

Note

history.back() will only work if a previous page exists in the history list.

See Also:

The history.back() Method

The history.forward() Method

The history.go() Method

Syntax

history.length

Parameters

NONE

Return Value

Type Description
A numberThe number of entries in the history list.

Browser Support

history.length() is supported in all browsers:
Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes