Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created September 22, 2015 11:14
Show Gist options
  • Save andreasvirkus/63d23147297b8fddeae0 to your computer and use it in GitHub Desktop.
Save andreasvirkus/63d23147297b8fddeae0 to your computer and use it in GitHub Desktop.
var newHash = '',
$mainContent = $('#content');
$('nav').delegate('a', 'click', function() {
window.location.hash = $(this).attr('href');
return false;
});
// Not all browsers support hashchange
// For older browser support: http://benalman.com/projects/jquery-hashchange-plugin/
$(window).bind('hashchange', function() {
newHash = window.location.hash.substr(1);
$mainContent.load(newHash + " #content > *");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment