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.

Syntax:

object.length;
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:
<head>
    <script type="text/javascript">
        function GetHistoryLength () {
            alert (window.history.length);
        }
    </script>
</head>
<body>
    <button onclick="GetHistoryLength ()">Get the number of documents in history!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content