嗨,我有一个问题,我要从这里重建gingerhost html5 pushstate演示: http://html5.gingerhost.com/
我将其复制到了我的网站,该网站位于: https://statusbilder.eu
所以我现在的问题是:我需要如何配置.htaccess文件才能使其正常工作? 为了使其正常工作,我是否必须创建一个具有相同内容的完整新文件?
这是推脚本
// THIS IS WHERE THE MAGIC HAPPENS
$(function() {
$('nav a').click(function(e) {
$("#loading").show();
href = $(this).attr("href");
loadContent(href);
// HISTORY.PUSHSTATE
history.pushState('', 'New URL: '+href, href);
e.preventDefault();
});
// THIS EVENT MAKES SURE THAT THE BACK/FORWARD BUTTONS WORK AS WELL
window.onpopstate = function(event) {
$("#loading").show();
console.log("pathname: "+location.pathname);
loadContent(location.pathname);
};
});
function loadContent(url){
// USES JQUERY TO LOAD THE CONTENT
$.getJSON("maincat.php", {cid: url, format: 'json'}, function(json) {
// THIS LOOP PUTS ALL THE CONTENT INTO THE RIGHT PLACES
$.each(json, function(key, value){
$(key).html(value);
});
$("#loading").hide();
});
// THESE TWO LINES JUST MAKE SURE THAT THE NAV BAR REFLECTS THE CURRENT URL
$('li').removeClass('current');
$('a[href="'+url+'"]').parent().addClass('current');
}
然后推送的网址如下:
结果从文件中给出:maincat.php json格式,我用php从链接click.get的获取值中生成。不是想法还是解决方案?