function ajaxUrl(link) {
$.ajax({
url: link.replace(/[#]/gi, ''),
method: 'get',
dataType: 'html',
cache: false,
success: function(data) {
$('#content').html(data);
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
});
}
if(history.pushState){
$(window).on('popstate', function(event){
var loc = event.location || ( event.originalEvent && event.originalEvent.location ) || document.location;
ajaxUrl(loc.href);
});
}
$('#content').on('click', 'a', function(e) {
var link = $(this).attr("href");
if(link != null) {
ajaxUrl(link);
history.pushState(link, link, '#' + link);
e.preventDefault();
}
});