History.length

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

history.length

Description

The length property of the History object is used to get the number of URLs in the history list.

Example

Listing 7.298 shows an example of how the length property is used to determine how many URLs are in the history list.

Listing 7.298 Example of the length Property
<html>
<head>
<title> Using the length property of the History object</title>
</head>
<body>

<script language="JavaScript">
<!-- Hide
//write the number of elements in the history list
var numOfURL = window.history.length;
document.write("The number of URL's in the history list is: " + numOfURL);
// End Hide
</script>

</body>
</html>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.