PDA

View Full Version : history object and back/go methods


tomhilton
02-23-2003, 04:42 PM
Hi, I'm completely new to Javascript, use php/html/mysql, but I need to be able to return visitors back to where they came from after visiting my page.

The page they are visiting has a number of buttons and links that are "refresh" types. The visitor can hit these different buttons, reloading the page with different information and adding to their history.length before they leave.

Is there a way to capture a specific history object as a variable (the page they came from when they first visit my page) and use that to return them back to that page, no matter how long or how many times they "refresh" on my page?

Or, should I keep track of the number of times they "refresh" on the page ($x) and use the following: onClick="history.go(-$x)"
I read somewhere that go() isn't as reliable as back().

Any ideas or suggestions would be appreciated.

FJbrian
02-23-2003, 05:46 PM
you'll find history to be a bit troublesome.
It depends on the individual's permissions he has set up on his computer plus(I believe) the site's he's coming from.
Can you wing something like this?
If history-1(last page)= history-2(two pages ago) then history-3(3 pages ago)=history-2(bumps up to 2 in your list)

tomhilton
02-23-2003, 05:57 PM
Thanks for your quick reply, I went ahead and tried the history.go($x), and it seems to be working on my test server. Is there a problem with go() as a javascript function?

FJbrian
02-23-2003, 06:07 PM
no idea if there's a prob with history.go
usually use back or forward
I would doubt there is a prob but instead(as I mentioned before) the security permissions set by your browser or the site you came from

Pasted:
The History Object contains a list of URLs in the browser’s history. This object requires signed scripts to access the actual string values of the array. The array is zero based.
WebScripter 4 Help

Also, may wanna just manipulate it via history.length
Pasted:
This value is the count of items in the history array.

Syntax:
var HistLength = history.length;

WebScripter 4 Help

Again, the "signed scripts" is gonna haunt you