1

I have set up a one-page, horizontal scrolling website with several anchors combined with DIV-id's. The website has five pages side-by-side that automatically render full-page based on the visitors browser-window.

The menu contains seven hyperlinks that address different anchors (div-id's) on the page (for example: http://www.url.com/#partsix). When they are clicked, the visitor will automatically be scrolled to the anchor part of the page. This works fine and really smooth.

The problem i'm dealing with is that, since the page is not being reloaded, the address-bar is not updated. So if a visitor wants to link to a page, or, for example, like the URL with a facebook button, it will be very difficult.

Is there a way to rewrite the address bar with the anchorlink without reloading the page?

EDIT: I have found out that i can user the action onclick="window.location.hash = hash;" on the hyperlinks. This will return the hash of the anchor it is scrolling to in the address bar. Works like a charm. But: my menu plugin does not let me add this action to the hyperlinks. So i wanted to check if i can use javascript to apply this action to all hyperlinks in the same li class. Does anyone know how?

The li class that contains all menu links is 'mc_menu mc_depth_2'

  • Possible duplicate of [Modify the URL without reloading the page](http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page) – Miguel-F Nov 28 '12 at 16:11
  • Hmm not sure if its a duplicate. What i want is to change the addressbar url when i click an anchorlink. The article you linked shows how to store the url's in history.. – Sjoerd de Jong Nov 28 '12 at 16:27
  • Did you read the accepted answer to that post? It references another one [Updating address bar with new URL without hash or reloading the page](http://stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page) – Miguel-F Nov 28 '12 at 16:36
  • It seems like i 'just want it the old way' with only the hash being changed in the addressbar when clicking a anchorlink. – Sjoerd de Jong Nov 28 '12 at 17:22
  • I found out i just have to add onclick="window.location.hash = hash;" to the Hyperlink. Testing now. – Sjoerd de Jong Nov 28 '12 at 18:36

0 Answers0