0

My problem is best described with this screencast I recorded: http://www.youtube.com/watch?v=aI-p_jqzOdU

I'm using the jQuery Address plugin for Ajax deep-linking. For those who don't know how jQuery address works, it works by listening to the hash changes with the change() method. Pressing the back button and pressing a hyperlink that goes to the previous page URL should behave the same way because they call the same event handler.

Here it is in pseudo code:

$address.change(function(event) {
    if (event.value != '/') { // is the image link
        Get the URL to be loaded
        Create an overlay, append it to body and set its height, width, opacity
        Put overlay on top of gallery
        Load URL into overlay then fade it in
        Set BODY to overflow: hidden
    } else { // is the gallery link
        Set BODY to overflow: auto
        Fade out overlay then remove it
    }
});

If you watch the video, you'll see that pressing the link to the previous page causes the scroll of the page to jump back to 0. Pressing the browser back button keeps it which the the desired behavior.

What could be wrong?

Aen Tan
  • 3,305
  • 6
  • 32
  • 52
  • I think this probably answers my question. http://stackoverflow.com/questions/1489624/modifying-document-location-hash-without-page-scrolling – Aen Tan Nov 30 '10 at 15:20
  • Ok I think I know what's wrong. The history remembers the scroll of the previous page and thus the back button keeps the scroll. The link to previous page generates a new history state and thus you are not back to a previous state but a new state with scroll at zero. – Aen Tan Nov 30 '10 at 15:50

1 Answers1

0

Ok I think I know what's wrong. The history remembers the scroll of the previous page and thus the back button keeps the scroll. The link to previous page generates a new history state and thus you are not back to a previous state but a new state with scroll at zero.

Aen Tan
  • 3,305
  • 6
  • 32
  • 52