Monday, February 21, 2011

How can I load data on a page based on this being added into the URL #a=1380369&i=23007472

On a php page with javascript (jquery) in the urel I would like to have something like this
idex.php?var=something*#a=1380369&i=23007472*

The page will load photos and have a next and previous link, when this is clicked on it will use ajax to load the new image into the page but I need to also change the URL to add someting like this to the end of it #a=1380369&i=23007472 and then everytime a new photo is loaded it will change the URL value. If a user were to copy and paste the URL of an image page the page needs to use the #a=1380369&i=23007472 values to load the correct image on that page.

The result I am trying to get is it will act like a regualr galler, you can use ajax to load new photo page but it will not be an actual redirect to a new page load, ajax will just pull what it needs. The part I need to know is how to access the #a=1380369&i=23007472 url data and load the appropriate stuff based on it.

From stackoverflow
  • You're looking for document.location.hash, which returns this part of the URL.

    Michael Greene : One could look at the way SammyJS uses this technique combined with change detection in `Sammy.HashLocationProxy`: http://github.com/quirkey/sammy/blob/master/lib/sammy.js#L154

0 comments:

Post a Comment