可以将< script>标签不能自行关闭? [英] Can the <script> tag not be self closed?
问题描述
我在我的网站上有这个代码
< script type =text / javascriptsrc =http:/ /code.jquery.com/jquery-1.4.4.min.js\"/>
< script type ='text / javascript'src ='/ lib / player / swfobject.js'>< / script>
swfobject不工作(未加载)。
将代码更改为:
< script type =text / javascriptsrc =http:// code.jquery.com/jquery-1.4.4.min.js\"></script>
< script type ='text / javascript'src ='/ lib / player / swfobject.js'>< / script>
工作正常。
被解析为HTML5。
我认为这很有趣。好的,授予已关闭的标签并且自动关闭标签不相同。所以我会理解,如果jQuery无法加载(虽然我觉得它荒谬)。
但我不明白的是,jQuery的加载,但以下,正确书写的标签,没有?
在HTML中,有些标签始终是自封闭的。例如,< hr>某些内容在这里< / hr>
没有任何意义。同样,有些标签不能自动关闭。 < script>
标记就是其中之一。
我不确定没有自闭的原因< script>
标签,但其原因可能来自标签始终包含代码的事实。再次,我不确定。
I had this code in my website
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"/>
<script type='text/javascript' src='/lib/player/swfobject.js'></script>
swfobject was not working (not loaded).
After altering the code to:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type='text/javascript' src='/lib/player/swfobject.js'></script>
It worked fine.
The document was parsed as HTML5.
I think it’s funny. Okay, granted a tag that is closed and a self-closing tag are not the same. So I would understand if jQuery couldn’t load (although I find it ridiciulous).
But what I do not understand is that jQuery loads but the following, correctly written tag, doesn’t?
In HTML, there are tags which are always self-closed. For example, <hr>Some content here</hr>
does not make any sense. In the same way, there are tags which cannot be self-closed. <script>
tag is one of them.
I am not sure about the reason of no self-closed <script>
tags, but the reason might come from the fact that the tag was intended to always contain code inside. Again, I'm not sure.
这篇关于可以将< script>标签不能自行关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!