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. 19.Extjs主页面显示js

    1. /** * @author sux * @time 2011-1-11 * @desc main page */ var mainPage = Ext.extend(Ext.Viewport,{ ...

  2. 【WIP_S4】栈

    创建: 2018/01/15 更新: 2018/01/24 更改标题 [[WIP_S3]堆] => [[WIP_S4]堆] 继续添加内容 更新: 2018/05/13 更改标题  [[WIP_S ...

  3. bzoj 1232: [Usaco2008Nov]安慰奶牛cheer【最小生成树】

    有趣 每条边在算答案的时候被算了二倍的边权值加上两个端点的权值,然后睡觉点额外加一次 所以可以用这个权做MST,然后加上点权最小的点 #include<iostream> #include ...

  4. P3482 [POI2009]SLO-Elephants

    传送门 首先,交换关系肯定是构成一个环的时候最优 如果这个环是自环,不用交换了 如果环的大小为2,直接交换便是 否则的话,我们可以用环里最小的点最为交换媒介,然后去和其他交换直到到达正确的位置,那么环 ...

  5. 二分图最大匹配(匈牙利算法) POJ 3041 Asteroids

    题目传送门 /* 题意:每次能消灭一行或一列的障碍物,要求最少的次数. 匈牙利算法:把行和列看做两个集合,当有障碍物连接时连一条边,问题转换为最小点覆盖数==二分图最大匹配数 趣味入门:http:// ...

  6. 基于Web的Kafka管理器工具之Kafka-manager安装之后第一次进入web UI的初步配置(图文详解)

    前期博客 基于Web的Kafka管理器工具之Kafka-manager的编译部署详细安装 (支持kafka0.8.0.9和0.10以后版本)(图文详解) 基于Web的Kafka管理器工具之Kafka- ...

  7. SVN版本库的备份及迁移

    备份某个版本库:打开控制台窗口 1.备份某个版本库: svnadmin dump myrepos > dumpfile //将指定的版本库导出成文件dumpfile eg:svnadmin du ...

  8. Git学习笔记(2)-创建仓库

    一.Git简介 1.Git是什么 Git是分布式版本控制系统 2.Git有什么特点 (1)Git是分布式的SCM,SVN是集中式的 (2)Git每个历史版本存储完整的文件,SVN存储文件差异 (3)G ...

  9. gdb如何保存和读取断点

    刚开始在linux下学编程使用gdb的同学可能会发现,每次用gdb设置断点调试程序,但下次打开的时候所有断点都没有了,很不方便.下面介绍保存和读取断点的方法. 1. 保存断点 先用info b 查看一 ...

  10. HTML——meta

    http://www.cnblogs.com/jr1993/p/4542862.html