SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    hit back button -- go to TOP of page..

    after hitting 'back' button I'm taken to spot on page where I was, but I'm being asked to do the opposite -- take user to the top of the page, after hitting 'back' button...

    when I look up this issue, most people complain of the opposite - that the browser takes them to to top of the page after hitting 'back' button...;-)

    http://www.google.com/search?q=javas...ient=firefox-a

    is there a way with JavaScript to force page to go to the top of the page when you navigate to a back via 'back' button?

    thank you..

  2. #2
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    oops.. in that last sentence meant:

    is there a way with JavaScript to force the browser to take user to the top of the page when they navigate to a page via 'back' button?

    thank you..

  3. #3
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Not that I'm aware of, most browsers don't trigger a refresh when you use the navigation buttons so even if you had a script, there's no effective way to detect that the back button was clicked and that the action you want should be undertaken. The only way I can think of which may be able to do the trick is to give links the anchor fragment # (so like index.html#) thereby the browser "should" see that it needs to go to a section of the page and as there's no fragment identified it should jump to the top of every page by default. Hopefully that might work, but otherwise you're probably out of luck in this case.

  4. #4
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    yeah, I thought so.. it's just that I was asked to do this at work and wanted to be 100% that it was undoable when I told them.. ;-) thank you..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •