zoukankan      html  css  js  c++  java
  • type="application/javascript"

        type="application/javascript"

    html script 标签中 type有如下这些值,请问分别是什么意思,在什么情况下使用?
    • type="text/javascript" 
    • type="application/javascript" 
    • type="application/x-javascript" 
    这3个有什么区别吗 ?
     
    1. The traditional MIME type forJavaScript programs is "text/javascript".Another type that has been used is "application/x-javascript"(the "x" prefix indicates that it is an experimental, nonstandard type). RFC 4329 standardized the "text/javascript" type because it is in common use.However, because JavaScript programs are not really text documents, it marks this type as obsolete and recommends "application/javascript"(without the "x-") instead.At the time of this writing,"application/javascript" is not well supported, however.That might be the reason why "application/x-javascript" is used by a lot of webpages.
     

    大致意思是:传统的javascript程序的MIME类型是“text/javascript”,其他使用的还有"application/x-javascript"(x前缀表示这是实验性的,不是标准的类型),RFC4329规定了“text/javascript”类型,因为它普遍被使用。然而,javascript程序并不是真正的文本文件,这就表示这个类型已经意味着过时了,而推荐使用"application/javascript"(去除x前缀)。然而,在写程序的时候,"application/javascript"没有很好的支持。这也就是"application/x-javascript"不被使用在很多网页中的原因。

    您是否很疑惑为什么我们没有在<script>标签中使用 type="text/javascript"
     

    在 HTML5 中,不必那样做了。JavaScript 是 HTML5 以及所有现代浏览器中的默认脚本语言!





  • 相关阅读:
    【Day 04】 德州实行最严堕胎法,女性权益何去何从?
    【Day 03】 刚出生就遭遇疫情的娃娃们,将受到哪些影响?
    【Day 01】 房子不用买了,打印出来就能住:3D打印将如何改变居住生态?
    docker安装mysql-MacBook pro m1芯片
    jmeter调接口报415
    安装jenkins
    好用的编辑器总结
    屏障、释放一致性及原子操作
    Java的锁机制
    Java线程模型
  • 原文地址:https://www.cnblogs.com/moyuling/p/5011741.html
Copyright © 2011-2022 走看看