Php – How to use arrows to change page in jquery


With jquery I need to do something like this…

A user will follow a link to a users photo gallery on my social network site. A photo will load on the page and comments related to that photo with paging will be under the photo. Basicly this photo and comments will be a seperate page that is loaded in with AJAX, then when a user presses the left or right arrow key, I would like to load a different photo/comments page into the page.

So far it sounds pretty simple I think but I would like to append something to the URL when a new page is loaded. Lets say a page will be like this in the URL photos.php?user_id=2342323&photo_id=4234124 when they use arrow to load next image it should change to add something like this on #3523543 then when a user copy/paste that URL it would load the correct photo in the browser.

Any ideas how to do this in jquery?

Best Solution

A simple jQuery keyup listener will be more than sufficient to fill that role.

Basically, you take advantage of a browser quirk that allows you to rewrite the URL with

window.location = 'something';

without reloading the page. Then you implement a client-side listener to create the resultant permalink.