Script type 屬性
定義和用法
type
屬性設置或返回腳本的 type 屬性 的值。
type 屬性規定腳本的 MIME 類型。
type 屬性標識 <script> 和 </script> 標記之間的內容。
MIME 類型由兩部分組成:一種媒體類型和一種子類型。對於 JavaScript,MIME 類型是 "text/javascript"。
註釋:在 HTML5 中,不再需要 type 屬性。默認值即是 "text/javascript"。
另請參考:
HTML 參考手冊:HTML <script> Type Attribute
HTML 參考手冊:HTML <script> Tag
語法
返回 type 屬性:
scriptObject.type
設置 type 屬性:
scriptObject.type = MIME_type
屬性值
值 | 描述 |
---|---|
MIME_type |
規定腳本的 MIME 類型。 常用值:
Please See IANA MIME Types, to get a complete list of standard MIME types. |
Technical Details
Return Value: | A string value representing the MIME type of the script. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |