michalc Posted July 21, 2008 Share Posted July 21, 2008 Hi, I'm trying to make an Ajax gallery, and (using Mootools and HistoryManager) I can: - Set the address hash when changing photos (e.g. for the 4th photo the address ends with #photo(4) etc..) - Read the address hash when manually changing the address This degrades to a non-ajaxed gallery: - So links to larger images are of the form photos/4/ say (which are converted to say photos.php?num=4 using .htaccess), and the correct image shown using a bit of php - In these "non ajax" pages, I can have some javascript that automatically forwards the user from photos/4/ say to #photos(4) if javascript is enabled. Thus this automatically "upgrades" to the ajax gallery. However, I would also like to handle the case where a non-javscript user uses one of the ajax hash addresses. Say they get a link from a friend ending in #photos(4). I have thought about processing the hash server-side, and automatically forwarding to /photos/4/, but then if the user has javascript turned-on, they will be forwarded to #photos(4) by the automatic-upgrading Javascript, and so end up in an endless loop! Is there a way to handle the case of a non-javascript user using a hash address, and still show the correct photo? Michal. Quote Link to comment Share on other sites More sharing options...
corbin Posted July 21, 2008 Share Posted July 21, 2008 Short answer, no. The hash isn't sent to the server. So, you can't use any server side thing to read it anyway. And without JS enabled, good luck reading it client side. There could be ways, I guess, but the only one I can think of is an anchor with the same ID, and that wouldn't work, because chances are, you would have to ruin your CSS. Quote Link to comment Share on other sites More sharing options...
michalc Posted July 21, 2008 Author Share Posted July 21, 2008 Ah... I didn't realise the hash wasn't sent to the server initially: that is annoying. (But thanks for letting me know before I went completely down the wrong path). I have just checked on Facebook actually: it now uses Ajax for various things, and it sets the hash appropriately. I copied the address of my profile: home.php#/profile.php?id=[myidhere] into a browser with Javascript turned off, and it did not show my profile, it showed the general home page at home.php. So I guess if they're not to worried about it, maybe I shouldn't be...? Michal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.