Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Script type Property

Script type Property

Script Object Reference Script Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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.
 一些常用的值:     
  • text/javascript (default)
  • text/ecmascript
  • application/ecmascript
  • application/javascript
  • text/vbscript
  • 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