Html Internet Explorer 是否支持 pushState 和 replaceState?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3722815/
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-08-29 04:31:05  来源:igfitidea点击:

Does Internet Explorer support pushState and replaceState?

internet-explorerhtmlpushstate

提问by David Johnstone

Does anybody know if Internet Explorer supports the history.pushState()and history.replaceState()methods for manipulating browser history? Considering these are just being implemented in Firefox 4, I'm not holding my breath, but does anybody know if they're coming in IE9?

有谁知道如果Internet Explorer支持history.pushState()history.replaceState()对方法操纵浏览器历史记录?考虑到这些只是在 Firefox 4 中实现,我并没有屏住呼吸,但是有人知道它们是否会在 IE9 中出现吗?

回答by dave1010

Probably the best site for browser compatibility information is CanIUse. Here's the section on history.

浏览器兼容性信息的最佳站点可能是CanIUse。这是关于历史的部分。

Summary - IE9: no, IE10: yes(as of platform preview 3)

总结 - IE9: no, IE10: yes(从平台预览 3 开始)

The first Release Candidate of IE9 (released 10th Feb 2011) does not support history.pushState or history.replaceState. Generally no new features are added after a product gets to RC stage so it is very unlikely that the final IE9 will support these methods.

IE9 的第一个候选版本(2011 年 2 月 10 日发布)不支持 history.pushState 或 history.replaceState。一般在产品进入 RC 阶段后不会添加新功能,因此最终的 IE9 不太可能支持这些方法。

Microsoft have a good overview for developersof the features IE9 does have.

Microsoft 对IE9 确实具有的功能的开发人员有一个很好的概述

Update: Internet Explorer 9 was launched(on 14th March 2011) and definitely does not support history.pushState()or history.replaceState().

更新:Internet Explorer 9 已发布(2011 年 3 月 14 日)并且绝对不支持history.pushState()history.replaceState().

Update 2: The current platform preview of IE10 still does not support pushState / replaceState.

更新 2:IE10当前平台预览仍然不支持 pushState / replaceState

Update 3: Platform Preview 3 of IE10 supports the history API!Details

更新 3:IE10 的 Platform Preview 3支持历史 API!细节

回答by Sebastian Patten

IE9 doesn't support it.

IE9 不支持。

You can however use a work around using a Polyfill to get the functionality - History.js https://github.com/browserstate/history.js.

但是,您可以使用 Polyfill 来获得功能 - History.js https://github.com/browserstate/history.js

Modernizr do a good job listing HTML 5 Polyfills here https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills.

Modernizr 在https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills 中列出了 HTML 5 Polyfills 。

The caveat is that it will add a query string to your URL in browsers that only support HTML 4 features.

需要注意的是,它会在仅支持 HTML 4 功能的浏览器中向您的 URL 添加查询字符串。

回答by QC-cheetah

Internet Explorer 10 introduces support for the History interface of the HTML5 draft specification, which includes methods that enable you to manage a site's history stack and URL.

Internet Explorer 10 引入了对 HTML5 草案规范的 History 接口的支持,其中包括使您能够管理站点历史堆栈和 URL 的方法。

The original link:https://msdn.microsoft.com/en-us/library/ie/hh920758(v=vs.85).aspx

原文链接:https: //msdn.microsoft.com/en-us/library/ie/hh920758(v=vs.85).aspx

回答by f0rmat1k

Btw you can get such error in reason of absolute path in pushState(). When i set relative path error was disappeared.

顺便说一句,由于 pushState() 中的绝对路径,您可能会遇到此类错误。当我设置相对路径时,错误消失了。