This commit is contained in:
LeuisKen 2015-06-16 21:17:02 +08:00
parent d3b1d42011
commit 01f1ee9c8a

View File

@ -0,0 +1,10 @@
---
layout: post
category: "frontend"
tag: [前端]
title: PJAXpushState和Ajax
---
<p>终于从漫长的休眠期中清醒过来改认真搞搞技术了。在研究手机触摸界面的时候接触到了PJAX这个东西先研究、笔记一下。</p>
<p>其实这个pushState这个东西就是在html5时代history新增的方法除了这个还有replaceState方法和onpopstate事件。可以说这几个方法是现在各种单页系统的基础。</p>
<p>这里引用<a href="http://www.zhangxinxu.com/study/201306/ajax-page-html5-history-api.html?area=pudong">张鑫旭大神的demo</a>当你点击左边选项卡的时候注意上边url的变化。在变化的时候整个页面都没有刷新url历史记录都是pushState方法加入的当用户点击后退时会触发onpopstate事件接下来用你的执行函数去渲染前一个让url和视图一一对应这样就ok了。</p>
<p>关于这里由于我自己还没有写demo之后自己写了demo以后再探讨一些细节的问题。</p>