Script type Property
Example
Get the MIME type of the script:
var x = document.getElementById("myScript").type
x The output is:
text/javascript
Try it »
Definition and Usage
The type property sets or returns the value of the type attribute of the script.
The type property specifies the MIME type of the script.
The type property identifies the content between the tags.
A MIME type consists of two parts: a media type and a subtype. For JavaScript, the MIME type is "text/javascript".
**Note:** In HTML5, the type attribute is no longer required. The default value is "text/javascript".
Browser support





All major browsers support the type attribute.
Syntax
Return the type property:
scriptObject
.type
Set the type property:
scriptObject
.type=
MIME_type
Attribute values
| Value | Description |
|---|---|
| MIME_type | Specifies the MIME type of the script. |
一些常用的值:
See IANA MIME Types, for a complete list of standard MIME types.
|Technical Details
| Return Value: | A string representing the MIME type of the script. |
|---|
Related Articles
HTML Reference Manual:HTML
Script Object