jQuery Address difference in behavior for browser back button vs link to previous page

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?

Answers


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.


Need Your Help

Symfony2: How to persist a new User in an admin-interface with FOSUserBundle?

php symfony2 fosuserbundle

I'm creating the admin view where i can list the users and create the users.

horizontal alignment label img div

html alignment label

Inside a long cell I have a image aligned to the left. Fine. Now I would like to insert a label right of the image that is aligned to the very right. When I try this the label appears always directly

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.