Forum Moderators: open
The page below works in Opera 6 but includes forward history in IE6, Mozilla 1.0.
I have 2 questions:
1/ Is there a way to make this test more accurate in IE5+ and/or Mozilla 1.0?
2/ Is it possible to get your actual position in the history array?
<html>
<title></title>
<body>
<script>
onload = function() {
if ((document.layers) ¦¦ (document.getElementById && !document.all)) {
var pages = history.length-1;
} else {
var pages = history.length;
}
if (pages != 0) {
alert("history.length = "+history.length+" page(s)")
} else {
alert("null")
}
}
</script>
</body>
</html>
Thanks for your help.
Use the history.length property to count the items in the history list. Unfortunately, this nugget of information is not particularly helpful in scripting navigation relative to the current location because your script cannot extract anything from the place in the history queue where the current document is located. If the current document is at the top of the list (the most recently loaded), you can calculate relative to that location. But users can use the Go/View menu to jump around the history as they like. The position of a listing in the history does not change by virtue of navigating back to that document. A history.length of 1, however, indicates that the current document is the first one the user loaded since starting the browser software.
A history.length of 1, however, indicates that the current document is the first one the user loaded since starting the browser software.
Shouldn't that read "since opening that particular browser window"? I'm an Opera shift/click addict, so you wouldn't want to count on my window histories to tell you too much about my trip around your site!