旧版浏览器中的HTML5样式脚本标记 [英] HTML5-style script-tags in older browsers

查看:80
本文介绍了旧版浏览器中的HTML5样式脚本标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经声明,在HTML 5中,可以使用脚本 -tags替换Javascript 而不使用任何属性,例如:

 < script> 
// javascript here
< / script>

使用HTML 5中的其他功能,您可以使用不同类型的多重填充来桥接什么旧浏览器不知道HTML 5,但可能脚本 -tag在任何旧浏览器中都有副作用



UPDATE :让我们将 IE6及更高版本 Firefox 2及更高版本<有具体的东西。

解决方案

这是无处不在 - 类型的默认值是你类型,由浏览器解释。我已经使用这个在每个网站我做过,从来没有遇到过问题。对于脚本也一样 - 没有指定默认值。



HTML4规范(http://www.w3.org/TR/html4/interact/scripts.html #h-18.2.1)说类型是必需的,虽然浏览器使用这是错误的(指定语言没有类型, application / javascript 而不是 type / javascript 等等。简而言之,浏览器被用于这是错误的,所以他们寻找脚本,甚至不解析属性,只要我能告诉。 >

It has been stated that in HTML 5 it's OK to use script-tags for Javascript without any attributes, like this:

<script>
  // the javascript here
</script>

With other features in HTML 5 you can use different kind of poly-fills to bridge what old browsers don't know about HTML 5, but can above script-tag have any side-effect in any old browser?

UPDATE: Let's set the limit at IE6 and above, along with Firefox 2 and above, to have something concrete.

解决方案

This is fine everywhere - the default value for type is the one you'd type anyway, as interpreted by browsers. I've used this on every site I've ever made and have never had problems. The same goes for script - no point specifying default values.

The HTML4 spec (http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1) says the type is required, though browsers are used to this being malformed (language being specified with no type, application/javascript instead of type/javascript etc. In short, browsers are used to this being wrong, so they look for script, and don't even parse the attributes as far as I can tell.

这篇关于旧版浏览器中的HTML5样式脚本标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆