Windows history.length

Example

Get the number of URLs in the history list:

let length = history.length;
Try it Yourself »

Description

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 Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.