Javascript Reference - History length Property








The length property returns the number of URLs in the history list.

Browser Support

length Yes Yes Yes Yes Yes

Syntax

var v = history.length

Return Value

A Number type value representing the number of URLs in the history.





Example

The following code shows how to get the number of URLs in the history list.


<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var x = history.length;
document.getElementById("demo").innerHTML = x;
</script><!-- ww  w .  ja v  a 2s. c om-->

</body>
</html>

The code above is rendered as follows: