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. Java实现短信中提取号码

    Description 提取一条短信里所有的电话号码,电话号码之间换行打印,短信的内容由用户输入. Input 第一行有个整数n(1≤n≤1000)表示测试用例的个数.其后的每一行中有一条短信,每一条 ...

  2. 洛谷 P1433 吃奶酪(记忆化)

    题目描述 房间里放着n块奶酪.一只小老鼠要把它们都吃掉,问至少要跑多少距离?老鼠一开始在(0,0)点处. 输入输出格式 输入格式: 第一行一个数n (n<=15) 接下来每行2个实数,表示第i块 ...

  3. [C++ STL] 迭代器(iterator)详解

    背景:指针可以用来遍历存储空间连续的数据结构,但是对于存储空间非连续的,就需要寻找一个行为类似指针的类,来对非数组的数据结构进行遍历.因此,我们引入迭代器概念.   一.迭代器(iterator)介绍 ...

  4. C# 自动批量导入图片到数据库中

    using Model; using System; using System.Collections.Generic; using System.Data; using System.Data.Sq ...

  5. int 多少位,long 多少位

    Int16 值类型表示值介于 -32768 到 +32767 之间的有符号整数. Int32 值类型表示值介于 -2,147,483,648 到 +2,147,483,647 之间的有符号整数. In ...

  6. NodeJs学习记录(四)初学阶段关于app.js里的一些重要配置

    app.set('views', path.join(__dirname, 'views')); 以上代码用于配置页面文件(例如 .ejs 文件)的根目录, 设置之后 访问 ./index 则等同于访 ...

  7. Objective-C设计模式——生成器Builder(对象创建)

    生成器 生成器,也成为建造者模式,同样是创建对象时的设计模式.该模式下有一个Director(指挥者),客户端知道该类引用用来创建产品.还有一个Builder(建造者),建造者知道具体创建对象的细节. ...

  8. Elasticsearch--更好的搜索_加权得分,脚本,同义词

    目录 Apache Lucene评分 Elasticsearch的脚本功能 脚本执行过程中可以使用的对象 使用自定义的脚本库 搜索不同语言的内容 使用加权影响得分 加权 function_score查 ...

  9. 介绍Git的17条基本用法

    本文将介绍Git的17条基本用法.本文选自<Python全栈开发实践入门>. 1.初始化Git仓库 Git仓库分为两种类型:一种是存放在服务器上面的裸仓库,里面没有保存文件,只是存放.gi ...

  10. React组件的防呆机制(propTypes)

    Prop验证 随着应用不断变大,为了保证组件被正确使用变得越来越重要.为此我们引入propsTypes.React.PropTypes提供很多验证器(valodator)来验证传入的数据的有效性.当向 ...