I’m trying to make my website pages load seamlessly. If you click a page on some of the links below you will see what I’m talking about.
when you click on the link it loads the information and /#!/ is added to the url. How do I add this feature so my pages load the same way? Is there a tutorial anywhere?
This is called a
hashchangeevent. You can change the value after the#!without reloading the page, then you can use AJAX to load the info you want. If you’re using a new browser that supports HTML5, then you can useHistory.pushStateto change the url bar in a similar way.Basically, you add an event to the links, change the URL (using
location.hashorpushState), and then you can you load the data via AJAX.Here is a decent example of
location.hash, and here’s one forpushState.For a good cross-browser solution, I suggest History.js.
If you want to use History.js, after adding the scripts to your page, you need to add a bit of JavaScript too.