Reputation: 10603
After reading online about hash-bangs. Ive decided to stick with our current url structure. Ive been developing a site and making it completely non-javascript. Im coming to a stage where i can start to upgrade some stuff to fancy javascript and ajaxy stuff.
To give a little info. Basically when a user visits the site, the homepage is the main area. It has some statistics and a box. In this box is a companys details with some call to action buttons (go to map, contact, e.c.t.).
When searching for a company, or directly linking to a company you go to
http://mysite.com/company/company-name
This is then url rewritten by apache to
http://mysite.com/index.php?company=company-name
Where then my php script loads the box up with teh company details e.c.t.
Now ive come to do some ajaxy stuff. I want users to be able to click company links on my site and also use the search without having to reload the page. So if they click on teh name of the top viewed company, a quick loading symbol goes in the box and then company details get loaded into that area.
Once again this isn't too much of an issue. I can do this many ways, classname binding or url regex binding with click handlers on anchors.
However, heres my problem. I need to be able to change the URL so it always reflects the the companys name. Users share links by copy and pasting urls. Even if i provide a "click to copy to clipboard" permalink button, they will hardly use it. Ebay is a classic example, they provide nice url's for sharing, but its common to see the long ones posted on forums around the place.
Hashbangs or another fragmented url approach would allow me to do this. and i could also attach javascript handlers to the document.load so i can populate the box when a user visits the site from a fragmented url. However if a non-javascript user visits the site using a fragmented url, they will just get the homepage and will have to manually search for teh company.
Given the time and effort ive put into doing everything non-js to begin with. I dont now want to ruin that or have to make a decision on whether to dump the non-js users. However ajax loaded content is very important and so is sharing url's.
The ideal solution would either be a way of php reading the fragmented url, or a way of javascript changing the url path
Can anyone help with this ?
P.S: apologies for the essay on this. just wanted to give as much info as possible and share the what ive found from research to save time going over things i may have already looked at
Upvotes: 0
Views: 280
Reputation: 57184
Take a look at the AJAX system I built WITHOUT using hashtags. It uses window.history
in modern browsers and falls back for older ones that don't support cool AJAX stuff.
http://xeoncross.github.com/MicroStream/
You can see it live on my site: http://xeoncross.com
It's less than 10kB of simple, well commented code so you should be able to grasp it no problem.
Upvotes: 1