469,332 Members | 6,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Using history.go() to get to the *last* item in the history

When I say 'last', I mean (eg.) the 100th item in a 100-item history
list, *not* the immediately previous one!
The problem is, the history.go() method only allows *relative* movement
through the history list. I need to go directly to the end -- an
*absolute* movement -- and there doesn't appear to be any way of
finding out the number of 'steps' that would require.

Ideally, what I would use would be something of the form:

history.go(history.length - history.mythic_current_position_attribute);

....but that attribute appears to be a product of my fevered
imagination, or at least isn't documented anywhere.

Can anyone help? The idea is that if anyone uses the drop-down 'go back
many items' control in their browser, the site immediately bumps them
forward to where they came from; currently I have this implemented as
history.go(+1) at the top of each page, but this can end up with a
chain of 10+ page requests, which is rather too easy to interrupt.

(Aside: why do I keep getting 'permission denied' errors when I try to
access history.current via Firefox?)
Thanks in advance,

Niall

Dec 4 '06 #1
3 2072
Niall wrote:
When I say 'last', I mean (eg.) the 100th item in a 100-item history
list, *not* the immediately previous one!
The problem is, the history.go() method only allows *relative* movement
through the history list. I need to go directly to the end -- an
*absolute* movement -- and there doesn't appear to be any way of
finding out the number of 'steps' that would require.

There's a reason for this. You're bumping into the walls of the
browser's sandbox meant to keep your site relatively isolated from the
user's private data. Imagine if the history was accessible....

Welcome Mr. Smith. Amazorn.net is your one button shopping experience.
We see that you recently visited monkeyspankingsex.com, there will be an
additional $100.00 charge to your account tonight unless you'd like us
to email Mrs. Smith your browser history.

Ewww.

Since you appear to want to navigate only within your own site, you can
make your own history model with the use of cookies. That's a lot of
work really (and probably why people responsible for browser standards
weren't falling all over themselves to make the history list more
accessible for in-site navigation). If you decide to implement cookies,
remember there's a size limit per site (off the top of my head I'd say
it's 4k) and a lot of (very smart) people surf with cookies OFF unless
deliberately turned on, on a site-by-site basis.

---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Dec 4 '06 #2
pcx99 wrote:
There's a reason for this. You're bumping into the walls of the
browser's sandbox meant to keep your site relatively isolated from the
user's private data. Imagine if the history was accessible....
I thought that might be the case. Ah well...
Since you appear to want to navigate only within your own site, you can
make your own history model with the use of cookies.
Not exactly; the idea is that someone who leaves the site shouldn't be
able to get back to it using the back button (it's a secure office
productivity web app, and we can't rely on the users logging out
properly if they leave the site, then wander away from their desks with
the browser still open), however I might be able to come up with
something similar.

Ta much...

Dec 5 '06 #3
Update - because Internet Explorer (6, anyway, and we can't support 7
yet) doesn't send referer info with JavaScript page requests, a
referer/request checking system doesn't work either.

Dec 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Dan | last post: by
8 posts views Thread by Ed Jay | last post: by
1 post views Thread by George | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.