最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - history.pushstate not working in IE8 - Stack Overflow

programmeradmin2浏览0评论

I am using window.History.pushstate. It works fine in Chrome, but in IE8 it appends the path #. Please help.

Below is my code snippet:

  var History = window.History; 
  History.pushState(null, null, "/abc"); 

I am using window.History.pushstate. It works fine in Chrome, but in IE8 it appends the path #. Please help.

Below is my code snippet:

  var History = window.History; 
  History.pushState(null, null, "/abc"); 
Share Improve this question edited Mar 18, 2014 at 12:38 Paul D. Waite 99k57 gold badges203 silver badges271 bronze badges asked Mar 18, 2014 at 12:35 user3433077user3433077 311 gold badge1 silver badge2 bronze badges 2
  • 4 window.History isn’t supported in IE 8 (or, indeed, IE9. – Paul D. Waite Commented Mar 18, 2014 at 12:37
  • 1 window.History and window.history is not the same thing. window.history uses the HTML5 history API which ie8 can't use. window.History referes to History.js (see github./browserstate/history.js by Benjamin Lupton). History.js is almost the same as HTML5 History API only with fallback mechanisms for HTML4 only supported browsers. – Avec Commented Apr 14, 2014 at 9:28
Add a ment  | 

2 Answers 2

Reset to default 2

You wrote window.History. Did you include history.js by Benjamin Lupton? window.History and window.history is not the same thing as window.History referes to history.js and that makes the history backwards patible with html4 browsers.

Take a look at these two:

  • jQuery & history.js example
  • jquery.history.js VS jquery-hashchange

you can refer below answer

IE history push state

IE9 and below don't support pushState. You have an exception when calling the following line:

window.history.pushState(null, null, pathFullPage);

SCRIPT438: Object doesn't support property or method 'pushState' ?terms_and_conditions, line 62 character 21

You may probably be interested in looking at some workarounds discussed here: Emulate/polyfill history.pushstate() in IE

发布评论

评论列表(0)

  1. 暂无评论