html script标签 type,[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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值