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 以及所有现代浏览器中的默认脚本语言!

type="application/javascript"的更多相关文章

  1. 浅谈JS之text/javascript和application/javascript

    问题描述: JS在IE8以下浏览器运行异常 代码: <script>标签是这样子写的: <script type="application/javascript" ...

  2. <script language = "javascript">, <script type = "text/javascript">和<script language = "application/javascript">(转)

          application/javascript是服务器端处理js文件的mime类型,text/javascript是浏览器处理js的mime类型,后者兼容性更好(虽然application/ ...

  3. 关于Access restriction: The type 'Application' is not API (restriction on required library)

    原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是 ...

  4. CodeSign error: code signing is required for product type Application in SDK iOS

    在真机测试的时候往往会突然出现这样一个错误,code signing is required for product type 'Application' in SDK 'iOS 7.0'  ,就是说 ...

  5. jersey处理支付宝异步回调通知的问题:java.lang.IllegalArgumentException: Error parsing media type 'application/x-www-form-urlencoded; text/html; charset=UTF-8'

    tcpflow以流为单位分析请求内容,非常适合服务器端接口类服务查问题 这次遇到的问题跟支付宝支付后的回调post结果有关 淘宝的代码例子: public void doPost(HttpServle ...

  6. document.write('<script type=\"text/javascript\"><\/script>')

    document.write('<script type=\"text/javascript\"><\/script>')

  7. solrj6.2异常--Expected mime type application/octet-stream but got text/html.

    org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://19 ...

  8. odoo 错误 Resource interpreted as Stylesheet but transferred with MIME type application/x-css:

    odoo8   页面内容显示一半,  web 控制台显示错误  Resource interpreted as Stylesheet but transferred with MIME type ap ...

  9. solr异常--Expected mime type application/octet-stream but got text/html.

    Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrExce ...

随机推荐

  1. IDEA Artifacts问题

    如果你使用的IDEA并且无论如何都ClassNotFound异常的话,可以看看其中一种可能的解决方案 第一步:打开Project Struture-->Modules-->点击项目--&g ...

  2. bzoj 1741: [Usaco2005 nov]Asteroids 穿越小行星群【最大点覆盖】

    二分图最大点覆盖模型,因为对于一个点(x,y)显然只要选x或者y就好了,于是连边,跑最大匹配=最大点覆盖(不会证) #include<iostream> #include<cstdi ...

  3. activiti遇到的问题

    1.act_hi_detail表里面没有数据 原因是没有加历史变量的判断 2.流程图添加网关,写流转表达式 比如请假流程   大于3天小于5天的条件:${请假实体类.属性名称}

  4. LOJ#510. 「LibreOJ NOI Round #1」北校门外的回忆(线段树)

    题面 传送门 题解 感谢\(@M\_sea\)的代码我总算看懂题解了-- 这个操作的本质就是每次把\(x\)的\(k\)进制最低位乘\(2\)并进位,根据基本同余芝士如果\(k\)是奇数那么最低位永远 ...

  5. $CF55D [数位DP]$

    题面 数位DP+状压. 首先,按照数位DP的基本套路,每个个位数的最小公倍数为2520,所以只用考虑模2520的情况.考虑一个DP.dp[i][j][k]表示当前是第i位,2~9的数的集合为j,模25 ...

  6. laravel 模型 $table $guarded $hidden

     首先以App\User模型为例 1.$table属性 表名,对应数据库中的表名 2.guarded)属性 guarded表示在create()方法中不能被赋值的字段 3.$hidden属性 $hid ...

  7. java HashMap和LinkedHashMap区别

    我们用的最多的是HashMap,在Map 中插入.删除和定位元素,HashMap 是最好的选择.但如果您要按自然顺序或自定义顺序遍历键,那么TreeMap会更好.如果需要输出的顺序和输入的相同,那么用 ...

  8. 牛客练习赛17-A-长方体

    题目描述 给出共享长方体一个顶点的三个面的面积,求它十二条边的边长和. 输入描述: 一行三个整数a, b, c表示面积(1 <= a, b, c <= 10000). 输出描述: 一行一个 ...

  9. Android 性能优化(6)网络优化( 2) Analyzing Network Traffic Data:分析网络数据

    Analyzing Network Traffic Data 1.This lesson teaches you to Analyze App Network Traffic Analyze Netw ...

  10. php 5.6 版本配置 oracle ddl

    1. Windows版PHP内置了Oracle驱动,在ext目录下:php_oci8.dllphp_oci8_11g.dllphp_pdo_oci.dllLinux上如果自己编译的话则添加下面的con ...