您的位置:首页 > Web前端 > HTML5

ajax与HTML5 history pushState/replaceState实例

2015-09-17 17:11 549 查看
pushState:会将url保存起来,点击手机返回键会一个一个地冒泡似的返回,不能一下子返回第一个入口的页面。

replaceState:会替换url,点击返回,一下子就回到第一个入口的页面。

无刷新获取数据:


$("#xmonth").click(function(){
//下一个月
var smonth=parseInt(jsmonth)+1;
if(smonth>12){
smonth=1;
year=parseInt(year)+1;
}
jsmonth=smonth;
month=year+""+(smonth>=10?smonth:"0"+smonth);
getdata(openid,month);
history.replaceState({}, $(document).title, url);
})


原文链接:http://www.zhangxinxu.com/wordpress/?p=3432
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: