0

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 www.example.com/about, to get the about page, and would get updated in the browser when the page was clicked in the navigation.

dremme
  • 739
  • 2
  • 10
  • 18

2 Answers2

2

Your easiest bet is going to be to use hashes. i.e. www.example.com/#about

You 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.

Chris Sobolewski
  • 12,819
  • 12
  • 63
  • 96
0

You could load the page with Ajax

Eric Frick
  • 847
  • 1
  • 7
  • 18