[HTML] script標(biāo)簽的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.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,208評(píng)論 0 23
  • 目錄繁華落盡,亂世成殤 上一章繁華落盡,亂世成殤(28) “瓔兒!”歐陽澈生氣的看著白瓔,讓白瓔著實(shí)嚇了一跳,看著...
    煦子閱讀 347評(píng)論 12 7
  • 小公舉的臉有點(diǎn)胖兒兒兒兒 漸變畫的不好看⊙︿⊙ 步驟:
    dotdai閱讀 418評(píng)論 0 0
  • 如果有一天,你能夠解脫~ 希望你找一個(gè)人品好的,而不是長(zhǎng)得好的~ 如果有一天,你重獲自由~ 希望你找一個(gè)愛你一輩子...
    尋找JC那些年閱讀 202評(píng)論 0 0
  • 1、今天早起了半個(gè)小時(shí),不像原來那么匆忙了,輕松的準(zhǔn)備了早餐,輕松的感到了學(xué)校 2、按照朋友的要求穿禮服去參加了一...
    39f7f7b7eb2c閱讀 296評(píng)論 0 0

友情鏈接更多精彩內(nèi)容