javascript 如果我已经在使用 Modernizr,那么我还需要 HTML5 Shiv 吗?

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

If I'm already using Modernizr, will I then even need HTML5 Shiv?

javascripthtmlcsscross-browsermodernizr

提问by Jitendra Vyas

1) If I'm already using Modernizr, will I then even need HTML5 Shiv to enable HTML5 tag support for IE?

1) 如果我已经在使用 Modernizr,那么我是否还需要 HTML5 Shiv 来为 IE 启用 HTML5 标签支持?

2) Is HTML5 Shiv only for IE, or for all browser who don't have native HTML 5 support? Like older versions of Firefox, Safari, Chrome, etc?

2) HTML5 Shiv 仅适用于 IE,还是适用于所有不支持原生 HTML 5 的浏览器?像旧版本的 Firefox、Safari、Chrome 等?

回答by thirtydot

1) If I'm already using Modernizer then even will I need HTML5 Shiv to enable HTML5 tag supports for IE.

1) 如果我已经在使用 Modernizer,那么我什至需要 HTML5 Shiv 来为 IE 启用 HTML5 标签支持。

You don't need to separately include html5shiv, because Modernizr includes it:

您不需要单独包含html5shiv,因为 Modernizr 包含它:

As of Modernizr 1.5, this script is identical to what is used in the popular html5shim/html5shiv library.

从 Modernizr 1.5 开始,此脚本与流行的 html5shim/html5shiv 库中使用的脚本相同。

http://www.modernizr.com/docs/#html5inie

http://www.modernizr.com/docs/#html5inie



2) and is HTML5 Shiv only for IE or for all browser who don't have native HTML 5 support. like older version of Firefox, Safari, Chrome etc.

2) 并且是 HTML5 Shiv 仅适用于 IE 或所有没有原生 HTML 5 支持的浏览器。像旧版本的 Firefox、Safari、Chrome 等。

It's only for Internet Explorer.

它仅适用于 Internet Explorer。

Older versions of other browsers don't need it: http://caniuse.com/html5semantic

其他浏览器的旧版本不需要它:http: //caniuse.com/html5semantic

And the recommended snippet to include it is:

推荐的包含它的片段是:

<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Which will only ever run for IE less than 9.

这只适用于小于 9 的 IE。