Playing with Url Hash with Chrome and Safari

Edit
In the iPad web application I am building, we want to be able to bookmark a screen of content which is being injected to the DOM through Javascript. We know we could add hash into the URL for that particular block of content. However, we also have a little navigation within the web application.

First I tried to use

window.location.hash = my_hash

but that will give me wrong behavior on the our navigation (because a new history item is being added). Indeed, I should use

history.replaceState('', document.title, "#" + my_hash);

which will give me the behavior i want and the navigation works with it as well. There are indeed some other useful function for the History API in HTML5, you might want to take a look in Pushing and Popping with the History API | HTML5 Doctor

Playing with Url Hash with Chrome and Safari Playing with Url Hash with Chrome and Safari Reviewed by DF on 11:38:00 PM Rating: 5
©DF. Powered by Blogger.