You are here: Reference > JavaScript > client-side > browser > properties > length (history)

length property (history)

Browser support:
Returns the number of entries in the history list of the current browser window.
This property returns at least 1, because the history list includes the currently loaded page.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the number of entries.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the length property:
    <script type="text/javascript">
        function GetHistoryLength () {
            alert (window.history.length);
    <button onclick="GetHistoryLength ()">Get the number of documents in history!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content