javascript history.pushstate 在 IE8 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22479605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 23:14:25  来源:igfitidea点击:

history.pushstate not working in IE8

javascript

提问by user3433077

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

我正在使用window.History.pushstate. 它在 Chrome 中工作正常,但在 IE8 中它附加了路径#。请帮忙。

Below is my code snippet:

下面是我的代码片段:

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

回答by Avec

You wrote window.History. Did you include history.jsby 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 compatible with html4 browsers.

你写了 window.History。您是否包含了 Benjamin Lupton 的history.js?window.History 和 window.history 与 window.History 指的是 history.js 不同,这使得历史记录向后兼容 html4 浏览器。

Take a look at these two:

看看这两个:

回答by Neel

you can refer below answer

你可以参考下面的答案

IE history push state

IE历史推送状态

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

IE9 及以下不支持pushState. 调用以下行时出现异常:

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

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