可以将< script>标签不能自行关闭? [英] Can the <script> tag not be self closed?

查看:87
本文介绍了可以将< script>标签不能自行关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上有这个代码

 < 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.

这篇关于可以将&lt; script&gt;标签不能自行关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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