语言= QUOT; JavaScript的"与type =“text / javascript” [英] language="javascript" vs. type="text/javascript"
问题描述
为了将JavaScript添加到HTML中,我看到有人使用
< script language = javascript>
和
< script type =text / javascript>
似乎脚本是嵌入的还是外部的影响这个决定。
哪一个是首选的,为什么?
作为一个整洁的黑客,如果您放置了一个无效的 For adding JavaScript to HTML, I have seen people use and It doesn’t seem like whether the script is embedded or external influences this decision. Which one is preferred and why? In HTML 5, the As a neat hack, if you put an invalid 这篇关于语言= QUOT; JavaScript的"与type =“text / javascript”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< ;脚本语言=javascript>
曾用于非常旧的浏览器,并且已被弃用。
< script type =text / javascript>
是HTML 4标准。在HTML 5中, type
参数是可选的(JavaScript是默认的),所以你可以做< script>
。
type
,脚本将不会运行,但您仍然可以阅读JavaScript中的数据。一些模板库可以做到这一点。<script language=javascript>
<script type="text/javascript">
<script language="javascript">
was used in very old browsers, and is deprecated.<script type="text/javascript">
is the HTML 4 standard.type
parameter is optional (JavaScript is the default), so you can just do <script>
.type
, the script won't be ran, but you can still read the data in JavaScript. Some template libraries do this.