亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
Attributes accesskey (attribute) class (attribute) contenteditable (attribute) contextmenu (attribute) data-* (attribute) dir (attribute) draggable (attribute) dropzone (attribute) Global attributes hidden (attribute) id (attribute) itemid (attribute) itemprop (attribute) itemref (attribute) itemscope (attribute) itemtype (attribute) lang (attribute) slot (attribute) spellcheck (attribute) style (attribute) tabindex (attribute) title (attribute) translate (attribute) Elements a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 head header hr html i iframe img input input type="button" input type="checkbox" input type="color" input type="date" input type="datetime"-local input type="email" input type="file" input type="hidden" input type="image" input type="month" input type="number" input type="password" input type="radio" input type="range" input type="reset" input type="search" input type="submit" input type="tel" input type="text" input type="time" input type="url" input type="week" ins kbd label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt rtc ruby s samp script section select slot small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr Miscellaneous Attributes Block-level elements CORS enabled image CORS settings attributes Element Inline elements Kinds of HTML content Link types Microdata Optimizing your pages for speculative parsing Preloading content Reference Supported media formats Using the application cache Obsolete acronym applet basefont big blink center command content dir element font frame frameset hgroup image input type="datetime" isindex keygen listing marquee nextid noframes plaintext strike tt xmp
characters

HTML<script> 元素用于嵌入或引用可執(zhí)行腳本。

內容類別


Metadata content, Flow content, Phrasing content.

允許的內容

動態(tài)腳本,如文本/ JavaScript。

標記遺漏

沒有,起始和結束標簽都是強制性的。

允許父母

任何接受  metadata content 元素,或任何接受  phrasing content 的元素。

允許ARIA角色

沒有

DOM界面

HTMLScriptElement

屬性

這個元素包含全局屬性。

asyncHTML5該布爾屬性指示瀏覽器是否在允許的情況下異步執(zhí)行該腳本。該屬性對于內聯(lián)腳本無作用 (即沒有src屬性的腳本)。

動態(tài)插入的腳本默認情況下是異步執(zhí)行的,所以打開同步執(zhí)行(即腳本以加載的順序執(zhí)行)設置async=false

請參閱瀏覽器兼容性以獲取關于瀏覽器支持的注意事項。另請參閱asm.js的異步腳本。

crossorigin普通的script元素將最小的信息傳遞給window.onerror沒有通過標準CORS檢查的腳本。要允許對使用靜態(tài)媒體的單獨域的站點進行錯誤日志記錄,請使用此屬性。有關有效參數(shù)的更多描述性說明,請參閱CORS設置屬性。

defer這個布爾屬性被設置為向瀏覽器指示該腳本是在文件被解析之后,但在發(fā)射之前被執(zhí)行的DOMContentLoaded。如果該src屬性不存在(即內聯(lián)腳本),則不能使用該屬性,在這種情況下,該屬性不起作用。為了達到類似的動態(tài)插入腳本的效果,可以使用async=false

integrity包含內聯(lián)元數(shù)據(jù),用戶代理可以使用這些內聯(lián)元數(shù)據(jù)來驗證提取的資源是否已經交付,沒有意外的操作。請參閱子資源完整性。

nomodule此布爾屬性被設置為指示腳本不應該在支持ES6模塊的瀏覽器中執(zhí)行- 實際上,這可以用于將回退腳本提供給不支持模塊化JavaScript代碼的舊瀏覽器。

src此屬性指定外部腳本的URI; 這可以用來替代直接在文檔中嵌入腳本。如果一個script元素有一個src指定的屬性,它不應該在其標簽內嵌入一個腳本。

texttextContent 屬性一樣,這個屬性設置元素的文本內容。textContent 然而,與屬性不同的是,在將節(jié)點插入DOM之后,該屬性被評估為可執(zhí)行代碼。

type

指示表示的腳本的類型。此屬性的值將在以下類別之一中:

  • 省略或JavaScript MIME類型:對于符合HTML5的瀏覽器,這表示腳本是JavaScript。HTML5規(guī)范敦促作者省略該屬性,而不是提供冗余的MIME類型。在早期的瀏覽器中,這標識了嵌入或導入(通過src屬性)代碼的腳本語言。規(guī)范中列出了 JavaScript MIME類型。

  • module**:** HTML5對于符合HTML5的瀏覽器,代碼被視為JavaScript模塊。腳本內容的處理不受charsetdefer屬性的影響。有關使用的信息module,請參見深度:模塊中的ES6。

  • 任何其他值或MIME類型:嵌入式內容被視為不會被瀏覽器處理的數(shù)據(jù)塊。該src屬性將被忽略。

請注意,在Firefox中,您可以使用高級功能,例如稍后JS版本中的let語句和其他功能type=application/javascript;version=1.8。但是,要小心,因為這是一個非標準的功能,這很可能會打破對其他瀏覽器的支持,特別是基于Chromium的瀏覽器。

關于如何包含異國情調的編程語言,請閱讀關于Rosetta。

已棄用的屬性

languagetype屬性一樣,此屬性標識正在使用的腳本語言。type然而,與屬性不同的是,這個屬性的可能值從未標準化。type應該使用該屬性來代替。

注意

瀏覽器繼續(xù)解析頁面之前,立即獲取并執(zhí)行沒有asyncdefer屬性的腳本以及內聯(lián)腳本。

該腳本應該與text/javascriptMIME類型一起提供,但是瀏覽器是寬松的,只有在腳本使用圖像類型(image/*),視頻類型(video/*),音頻(audio/*)類型或者text/csv。如果腳本被阻塞,error則發(fā)送給元素,否則load發(fā)送事件。

例子

<!-- HTML4 and (x)HTML -->
<script type="text/javascript" src="javascript.js"></script>
<!-- HTML5 -->
<script src="javascript.js"></script>

規(guī)范

Specification

Status

Comments

HTML Living StandardThe definition of '<script>' in that specification.

Living Standard

Adds the module type

HTML5The definition of '<script>' in that specification.

Recommendation


HTML 4.01 SpecificationThe definition of '<script>' in that specification.

Recommendation


Subresource IntegrityThe definition of '<script>' in that specification.

Recommendation

Adds the integrity attribute.

瀏覽器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

1

(Yes)

11

(Yes)

(Yes)

(Yes)

async

1

(Yes)

1

(Yes)

(Yes)

(Yes)

crossorigin

30

(Yes)

13

No

12.5

(Yes)2

defer

(Yes)

(Yes)

3.53

104

No

(Yes)

integrity

45

No

43

No

?

No5

language

1

(Yes)

1

(Yes)

(Yes)

(Yes)

module

No

No

No

No

No

(Yes)

nomodule

(Yes)

No

(Yes)6

No

No

No

src

1

(Yes)

1

(Yes)

(Yes)

(Yes)

text

1

(Yes)

1

(Yes)

(Yes)

(Yes)

type

1

(Yes)

1

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

11

(Yes)

(Yes)

(Yes)

async

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

crossorigin

(Yes)

(Yes)

?

13

No

?

?

defer

(Yes)

(Yes)

(Yes)

1.0

No

?

(Yes)

integrity

45

45

No

43

No

?

No

language

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

module

No

No

No

No

No

No

(Yes)

nomodule

(Yes)

(Yes)

No

(Yes)6

No

?

No

src

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

text

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

type

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

Previous article: Next article: