history.pushstate在IE8中不起作用

时间:2014-03-18 12:35:19

标签: javascript

我正在使用window.History.pushstate。它在Chrome中运行良好,但在IE8中它附加路径#。 请帮忙。

以下是我的代码段:

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

2 个答案:

答案 0 :(得分:2)

你写了window.History。你有Benjamin Lupton的history.js吗? window.History和window.history与window不同.History引用history.js,这使得历史向后兼容html4浏览器。

看看这两个:

答案 1 :(得分:1)

你可以参考以下答案

IE history push state

IE9及以下版本不支持pushState。调用以下行时会出现异常:

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

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

您可能有兴趣查看此处讨论的一些变通方法:Emulate/polyfill history.pushstate() in IE