Is there a way to loop over the "history" object in javascript to find a specific page in the history?
+6
A:
Security reasons - no, you can not dump the history of the browser (with javascript)
I mean you can not do
for(i=0;i<window.history.length; i++)
{
alert(window.history[i]);
}
However I don't have good explanation why history.go(n);
is ok
Svetlozar Angelov
2009-12-22 15:14:23
`history.go(n)` is ok because it doesn't give you any information about the users history... it only sends them back to that location.
TM
2009-12-22 15:21:02
What about the properties current, next and previous ? can't they reveal the URLs ? Thanks
Mahesh Velaga
2009-12-22 15:23:49
Can anyone please clarify my question ? Thanks!
Mahesh Velaga
2009-12-22 15:27:42
No, those properties are no longer available to web scripting in any browser. `history.go()` isn't a security problem, but it's certainly a usability problem and should never be used.
bobince
2009-12-22 15:39:04
@bobince Thanks for the clarification :)
Mahesh Velaga
2009-12-22 16:07:55
+2
A:
No, because it would you the ability to basically spy on the web history of anyone visiting your site (you could send this information to your server using Javascript).
You can redirect the client to particular pages in their history using the Javascript history object's back(), forward(), and go() methods. You just can't know where exactly you're redirecting them (except in the case of using go() to redirect to a URL instead of a history number).
Kaleb Brasee
2009-12-22 15:18:18
A:
You can put that link on the page and check to see if it is visited.
tgandrews
2009-12-22 15:20:17