Skip to content

Instantly share code, notes, and snippets.

@Sysetup
Created July 19, 2016 23:19
Show Gist options
  • Save Sysetup/a57981c52a1d449aee19f71cd64c07fb to your computer and use it in GitHub Desktop.
Save Sysetup/a57981c52a1d449aee19f71cd64c07fb to your computer and use it in GitHub Desktop.
Load Ajax history browse
$('#pageslide .v-item, #menu-main a, #menu-main-1 a, #menu-secondary a').on('click', function () {
location.hash = $(this).attr('href').match(/(^.*)\./)[1];
return false
})
var originalTitle = document.title
function hashChange() {
var page = location.hash.slice(1);
if (page != "") {
$('#showHere').load(page + '.html');
document.title = originalTitle + ' + ' + page;
} else {
$('#showHere').load('includes/home.html');
}
}
if ("onhashchange" in window) {
$(window).on('hashchange', hashChange).trigger('hashchange')
} else { // lame browser
var lastHash = '';
setInterval(function () {
if (lastHash != location.hash)
hashChange();
lastHash = location.hash;
}, 100)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment