因爲window.history.pushState不適用於IE9等HTML 4瀏覽器,所以我查找了history.js,這是一個模擬pushState行爲的jQuery庫。在IE9中使用history.pushstate
問題是,使用pushState的時候,該URL的末尾是重複
例如,
History.pushState(null,null,window.location.pathname + '?page=1');
回報,
http://www.development.com/test.html#test.html?page=1
如何避免這個問題?非常感謝你。
更新(2012年/ 1/22),問賞金:
if (pageNo == 1){
//window.history.pushState({"html":currURL,"pageTitle":''},"", window.location.pathname + '?page=1'); For chrome and FX only
//History.replaceState(null,null,'')
//History.pushState(null,null,'?issue=' + currPageIssueNo + '&page=1');
}
else if (pageNo != 1 || pageNo == 1 && linkPageNo > 1 ) {
History.pushState(null,null,'?issue=' + currPageIssueNo + '&page=' + pageNo);
//window.history.pushState({"html":currURL,"pageTitle":''},"", newURL); For chrome and FX only
}
我還是遇到了問題,如果是第一頁
http://localhost/development/flipV5.html?issue=20121220&page=1
,當我去到IE9的第二頁,它有網址:
http://localhost/development/flipV5.html?issue=20121220&page=1#flipV5.html?issue=20121220&page=2
我會想實現是
http://localhost/development/flipV5.html?issue=20121220&page=2
如果這是不可能的HTML瀏覽器4,請至少達到
http://localhost/development/flipV5.html/#?issue=20121220&page=2
感謝好心幫
「 test.html的」理想情況下,應該是http://www.development.com/test.htm;?page=1是完美的,但似乎不可能 – user782104
此爲演示http://balupton.github.com/ history.js /演示/?狀態= 4 – user782104
嘗試,因爲http://balupton.github.com/history.js/demo/#?state=4 – Musa