Javascript History Length Property

Updated on 23 Mar 2012,
Published on 25 Jul 2008

Javascript History length property returns the number of URLs stored in the browser history for the current session of browser windows being used by the visitor. Javascript history length property returns the number value based on the counting method of web browser for example Microsoft Internet Explorer counts the history URLs from 0, FireFox counts the history items from 1 and Opera web browser counts the history items from 0. You can also test the history length property by getting the initial value in each browser. FireFox returns history length value as 1 whereas Internet Explorer and Opera returns 0.

JavaScript History Object Examples:

You can see the live samples and examples of JavaScript History Object from the following links:

Syntax for Javascript History Length Property

history.length

or

window.history.length

You can also access the history object length property through window object of javascript.

Example of Javascript History Length Property

<script type="text/javascript" language="javascript">
    document.write(history.length);
</script>

Above example code will write the output on the web page according the number of URL visited before opening the page having this code placed in the Head section of HTML document.

Output:

You can see the output of above discussed code from the following link:

JavaScript window.history.length

Continue to next tutorial: Javascript History Back Function  to learn how to navigate to previous link using JavaScript function.

0 Responses to "Javascript History Length Property"
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email