html tool

2017年8月22日星期二

js只修改url不重新加载的方式



参考:http://www.yduba.com/qianduan-2421711779.html
在ajax页面修改url为当前地址的方式:

比如:现在浏览器的地址是:http://www.study.com/index.html,想让浏览器跳转到其它地址,只需要很简单的一句:
var stateObj = { foo"bar" };
history.pushState(stateObj, """bar.html");
运行之后,发现浏览器地址变了,页面内容并没有刷新,如图:(直接用的 chrome 操作)
若水GIF截图_2017年2月17日16点0分28秒.gif

没有评论:

发表评论