Jump to content

Ajax-ed Javascript-on link (using hash) used by Javascript-off browser


michalc

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.