January 20, 2000 - The history Object
January 20, 2000 The history Object Tips: January 2000
Yehuda Shiran, Ph.D.
|
window.history
object. This object lets you deal with the history list but not with its exact data. That is, the URLs maintained in that list cannot be extracted or otherwise modified by a script. The only property of this object is its length. Its methods enable you to load the list's entries but not to manipulate the URL explicitly. Since the history
object is a property of the topmost window
object, you have the option to refer to it as window.history
or simply history
.
You can access the number of entries in the history list via the history.length
property. It works exactly like the strings' and arrays' length
property. You can use this property to find how many pages the user has visited lately:
if (history.length) > 10
alert("You've already accessed " + history length + " Web pages this session");
else
alert("You've only accessed " + history.length + " Web pages this session");