Created
July 19, 2016 23:19
-
-
Save Sysetup/a57981c52a1d449aee19f71cd64c07fb to your computer and use it in GitHub Desktop.
Load Ajax history browse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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