Prevent hash navigation url

Posted by Koningh on Stack Overflow See other posts from Stack Overflow or by Koningh
Published on 2012-07-04T21:13:22Z Indexed on 2012/07/04 21:15 UTC
Read the original article Hit count: 176

Filed under:
|

I have the following problem: I'm using a slider (coda) to let people navigate trough some 'pages'. The slider uses hash links to navigate to the next page/slide. If a user is at page one (#page1), there is a link which will lead the user to page 2 (#page2) and so on. At the top of the slider the numbers of the pages appear as a link, but only when the page is visited. So if there are six pages and the user navigates from the first to the second and then the third one, there are only three links at the top of the slider (to page one, two and three).

The problem is that a user can navigate to page five (or any page actually) without first visiting the pages previous to page five by just using the hash URL and typing the whole link in their address bar. For example if I would type

www.mydomain.com/slider/index.php#page5

the slider automatically navigates to the fifth slide/page of the slider and thereby skipping the first four. I want to allow users to navigate to #page5 only if they have visited the first four (So by clicking trough the slides). This means that if they would go to #page5 directly by typing the URL in the address bar, I would like them to be send to the first page (#page1).

Does anyone have any idea on solving this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery