Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement github.com file seamless file navigation

I just noticed a recent change when browsing github repositorys. When you select a file or folder, the new file slides in and pushed the old file out. This is easy enough to do with jquery, but what's really different is that the URL itself actually changes so that bookmarks still work. I've been struggling to create this for a book navigating site I'm working on but haven't been able to update the url without a full page refresh. Any ideas on how github does this?

like image 795
Paul Alexander Avatar asked Jan 28 '26 03:01

Paul Alexander


1 Answers

It's using the new HTML5 API history.pushState/history.replaceState for doing this (so it only works in modern browsers).

See https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries for more details.

If you want a solution for all browsers, then you have to stick to modifying the fragment (the bit after the #)

like image 186
Conrad Irwin Avatar answered Jan 29 '26 19:01

Conrad Irwin