tags:

views:

35

answers:

1

I have a navigation system on my site that uses javascript to slide horizontally stacked divs left and right into view. I'm trying to make the site function better with javascript turned off, so I have a second navigation system that uses hash values to 'go to' the appropriate section.

The problem arises if someone is on say http://mysite.com/#page2 then turns javascript on. The page reloads at the #page2 section which then causes the javascript enabled navigation system to not work correctly. e.g. it reloads thinking the page is at section 1 when it is actually displaying section #whatever.

I have tried adding parent.location.hash = ''; but when the page reloads, it still stays on whichever section it was on.

Any ideas on how to make the page fully refresh when javascript gets turned on?

A: 

Haven't tested this but, you could have a javascript state variable. When javascript first executes, it sets the state variable to true, checks if the url is the base one or a page section, then reloads to the root url (mysite.com). If the state variable is already true, it won't reload the page (so that you don't continually reload). Since the variable is in the javascript engine, it wouldn't be set to true yet if javascript just got turned on.

Here is an example of using javascript to parse the URL. In your case you'd pretty much just be looking for the # symbol.

rossdavidh
Thanks, I can use something like this actually. I've put an if statement checking for the hash signifiers for each of my sections, and if present, use a regexp to reload the page without any hash value. The only downside is I need to check for each of the possible hash values. -- I do need to check possible values as opposed to any value because I have two hash values that I will need present when JS is enabled.
aperture