关于javascript:为什么自关闭脚本元素不起作用?

Why don't self-closing script elements work?

浏览器无法正确识别的原因是什么:

1
<script src="foobar.js" /> <!-- self-closing script element -->

只有这样才能识别:

1
<script src="foobar.js">

这是否打破了XHTML支持的概念?

注意:此声明至少对所有IE(6-8测试版2)都是正确的。


XHTML 1规格说明:

3。元素最小化和空元素含量

Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use

and not

).

xhtml dtd将脚本元素指定为:

1
2
<!-- script statements, which may include CDATA sections -->
<!ELEMENT script (#PCDATA)>