The length property returns the number of URLs in the history list of the current browser window.
Get the number of URLs in the history list:
var x = history.length;
This example is opened in a new frame and will be treated as a new "session".
<!DOCTYPE html> <html> <body> <p>Number of URLs in history list:</p> <p id="demo"></p> <script> var x = history.length;//from w ww. j a v a2 s . c om document.getElementById("demo").innerHTML = x; </script> </body> </html>
The property returns at least 1, since the list has the currently loaded page.
Maximum length is 50.
This property is read-only.