views:

84

answers:

2

I have a site that I just converted to use anchor navigation..

hwww.site.com/shows is now www.site.com/#shows

It loads the info from the /shows directory to a div and adds the hash tag to tell you where you are.

The problem is, if you go to www.site.com/shows, the content is still there, but unstyled. How can I get it to redirect without going into an infinite loop of redirects?

I'm sure I explained that terribly, hopefully you guys get it.

A: 

What I do on my site is something like:

if(window.location.href.indexOf('#')==0)
{
    window.location.href='/#shows';
}
webdestroya
using this solution, how does that work if i have multiple directories that are being accessed? do i have to make a call for each one?
Craig Fowler
This just basically transforms whatever page the user goes to (probably some permalink) and then updates it to use the ajax version instead. You would have to place this on every page that needed to be fixed (so yea each directory)
webdestroya
A: 

jQuery Ajaxy includes this by standard with the redirect option. You can see this in action in a upcoming website here.

Without the hash: http://staging.balupton.com/projects/jquery-lightbox

Will redirect to: http://staging.balupton.com/#/projects/jquery-lightbox

To use it is surprisingly simple and straightforward (especially considering what it allows you to do!), and the support is fantastic. You can check out demos and usage examples and instructions at it's home page: http://www.balupton.com/sandbox/jquery-ajaxy/demo/

balupton