I’m developing a simple one page website, where the pages scroll horizontally using the scrollTo() javascript library. I have a home / about / contact page. I was wondering if there was a way to still use some form of URL routing like http://www.example.com/about, to get the about page, and would get updated in the browser when the page was clicked in the navigation.
I’m developing a simple one page website, where the pages scroll horizontally using the
Share
Your easiest bet is going to be to use hashes. i.e.
www.example.com/#aboutYou can then use
window.history(more reading) in order to change the URL without a page reload. Specifically, you will be looking for history.pushState() or history.replaceState()Depending on what browser support you need, you might need something like History.js to fall back in IE.