[HTML] script标签的type属性

http://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#attr-script-type

(1)type attribute

The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a valid MIME type. The charset parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".

(2)script block's type

If either:
the script element has a type attribute and its value is the empty string, or
the script element has no type attribute but it has a language attribute and that attribute's value is the empty string, or
the script element has neither a type attribute nor a language attribute, then
...let the script block's type for this script element be "text/javascript".

Otherwise, if the script element has a type attribute, let the script block's type for this script element be the value of that attribute with any leading or trailing sequences of space characters removed.

Otherwise, the element has a non-empty language attribute; let the script block's type for this script element be the concatenation of the string "text/" followed by the value of the language attribute.

The language attribute is never conforming, and is always ignored if there is a type attribute present.

(3)scripting language

If the user agent does not support the scripting language given by the script block's type for this script element, then the user agent must abort these steps at this point. The script is not executed.


其中:

(1)valid MIME TYPE

http://www.w3.org/TR/2014/REC-html5-20141028/infrastructure.html#valid-mime-type

The term MIME type is used to refer to what is sometimes called an Internet media type in protocol literature. The term media type in this specification is used to refer to the type of media intended for presentation, as used by the CSS specifications.

A string is a valid MIME type if it matches the media-type rule defined in section 3.1.1.1 "Media Types" of RFC 7231. In particular, a valid MIME type may include MIME type parameters.

(2)Media Type

http://tools.ietf.org/html/rfc7231#section-3.1.1

3.1.1.1. Media Type

HTTP uses Internet media types [RFC2046] in the Content-Type
(Section 3.1.1.5) and Accept (Section 5.3.2) header fields in order
to provide open and extensible data typing and type negotiation.
Media types define both a data format and various processing models:
how to process that data in accordance with each context in which it
is received.

 media-type = type "/" subtype *( OWS ";" OWS parameter )
 type = token
 subtype = token

The type/subtype MAY be followed by parameters in the form of
name=value pairs.

 parameter = token "=" ( token / quoted-string ) 

The type, subtype, and parameter name tokens are case-insensitive.
Parameter values might or might not be case-sensitive, depending on
the semantics of the parameter name. The presence or absence of a
parameter might be significant to the processing of a media-type,
depending on its definition within the media type registry.

A parameter value that matches the token production can be
transmitted either as a token or within a quoted-string. The quoted
and unquoted values are equivalent. For example, the following
examples are all equivalent, but the first is preferred for
consistency:

 text/html;charset=utf-8
 text/html;charset=UTF-8
 Text/HTML;Charset="utf-8"
 text/html; charset="utf-8"

Internet media types ought to be registered with IANA according to
the procedures defined in [BCP13].

  Note: Unlike some similar constructs in other header fields, media
  type parameters do not allow whitespace (even "bad" whitespace)
  around the "=" character.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,880评论 0 23
  • 目录繁华落尽,乱世成殇 上一章繁华落尽,乱世成殇(28) “璎儿!”欧阳澈生气的看着白璎,让白璎着实吓了一跳,看着...
    煦子阅读 328评论 12 7
  • 小公举的脸有点胖儿儿儿儿 渐变画的不好看⊙︿⊙ 步骤:
    dotdai阅读 418评论 0 0
  • 如果有一天,你能够解脱~ 希望你找一个人品好的,而不是长得好的~ 如果有一天,你重获自由~ 希望你找一个爱你一辈子...
    寻找JC那些年阅读 195评论 0 0
  • 1、今天早起了半个小时,不像原来那么匆忙了,轻松的准备了早餐,轻松的感到了学校 2、按照朋友的要求穿礼服去参加了一...
    39f7f7b7eb2c阅读 295评论 0 0

友情链接更多精彩内容