【发布时间】:2011-06-10 03:37:14
【问题描述】:
如何检查您使用的浏览器是否支持 HTML5 history api?
正如你在这里看到的 http://caniuse.com/#search=history 只有 chrome +ff4 和其他几个支持这个,如果他们不能支持这个,我想做点别的。
我怎样才能为此检查创建某种 if 语句?
【问题讨论】:
标签: html pushstate html5-history
如何检查您使用的浏览器是否支持 HTML5 history api?
正如你在这里看到的 http://caniuse.com/#search=history 只有 chrome +ff4 和其他几个支持这个,如果他们不能支持这个,我想做点别的。
我怎样才能为此检查创建某种 if 语句?
【问题讨论】:
标签: html pushstate html5-history
您可以使用Modernizrdetect support 进行历史管理(以及许多其他浏览器功能)。
if (Modernizr.history)
【讨论】:
history
类添加到您的根 html
标记和 no-history
如果您不这样做。这可能不像flexbox
等其他功能那样特别有用,但如果你真的需要它,它可以让你根据这个功能更改css
if (window.history && window.history.pushState)
另见All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything
【讨论】:
您可以使用canisuse.js 脚本来检测您的浏览器是否支持历史记录
caniuse.history()
【讨论】: