HTML DOM Script type property
Examples
Get the MIME type of the script:
var x = document.getElementById("myScript").type
x The output is:
text/javascript
try it"
Definition and Usage
Value of the type property sets or returns the script type property.
type attribute specifies the MIME type of the script.
type attribute identifies the <script> and </ script> content between the tags.
MIME type consists of two parts: media type and subtype. For JavaScript, MIME type is "text / javascript".
Note: In HTML5, type attribute is no longer necessary. The default value is "text / javascript".
Browser Support
All major browsers support the type attribute.
grammar
Returns type attributes:
scriptObject .type
Setting type attributes:
scriptObject .type=MIME_type
Property Value
值 | 描述 |
---|---|
MIME_type | 规定脚本的 MIME 类型。 一些常用的值:
请参阅 IANA MIME 类型 ,获得标准 MIME 类型的完整列表。 |
technical details
return value: | String representing the MIME type of the script. |
---|
related articles
HTML Reference Manual: HTML <Script> of the type attribute