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

Discussion in 'Javascript' started by Niall, Dec 4, 2006.

  1. Niall

    Niall Guest

    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
     
    Niall, Dec 4, 2006
    #1
    1. Advertising

  2. Niall

    pcx99 Guest

    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
     
    pcx99, Dec 4, 2006
    #2
    1. Advertising

  3. Niall

    Niall Guest

    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...
     
    Niall, Dec 5, 2006
    #3
  4. Niall

    Niall Guest

    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.
     
    Niall, Dec 6, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johannes Zellner
    Replies:
    1
    Views:
    508
    Alex Martelli
    Jan 17, 2006
  2. mc
    Replies:
    0
    Views:
    748
  3. Sam Stephenson
    Replies:
    1
    Views:
    248
    Andrew Walrond
    Jun 18, 2005
  4. Replies:
    2
    Views:
    428
    nutso fasst
    Oct 17, 2006
  5. Nick Timkovich

    Generator using item[n-1] + item[n] memory

    Nick Timkovich, Feb 14, 2014, in forum: Python
    Replies:
    0
    Views:
    68
    Nick Timkovich
    Feb 14, 2014
Loading...

Share This Page