HTML5-style script-tags in older browsers

落花浮王杯 提交于 2019-12-12 17:51:18

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8401428/html5-style-script-tags-in-older-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!