English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript History length Property

HTML History Object

history.lengthA read-only property returns an integer (Integer) representing the number of elements in the session history, including the currently loaded page.

This property at least returns1, because the list includes the currently loaded page.

This property is very useful for finding out how many pages the user has visited in the current browsing session.

Syntax:

history.length
var result = history.length; // Returns the size of the history of the current session.
Test and See‹/›

Browser Compatibility

All browsers fully support the history.length property:

Property
history.lengthYesYesYesYesYes

Technical Details

Return Value:A number indicating the number of entries in the session history

Related References

History Record Reference:history.back() method

History Record Reference:history.forward() method

HTML History Object