You are here: Reference > JavaScript > client-side > HTML DOM > properties > type (script)

type property (script)

Browser support:
Sets or retrieves the type of scripting language to use.
In some older browsers the value of this property must be set, because there is no default value for this property.

Syntax:

object.type;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: type

Possible values:

String that sets or retrieves the type of scripting language.
One of the following values:
text/ecmascript
The language is ECMAScript.
text/javascript
The language is JavaScript.
text/jscript
The language is Microsoft JScript.
text/vbs
Same as text/vbscript.
text/vbscript
The language is Microsoft Visual Basic Scripting Edition.
text/xml
The language is XML.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the type attribute:
Code
javascript.js
<head>
    <script type="text/javascript" src="javascript.js"></script>
</head>
<body>
    <button onclick="HelloWorld ();">Call HelloWorld function</button>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the type property:
Code
javascript.js
<head>
    <script type="text/javascript" id="baseScript" src="javascript.js"></script>

    <script type="text/javascript">
        function GetScriptType () {
            var script = document.getElementById ("baseScript");
            alert ("The type of the first script: " + script.type);
        }
    </script>
</head>
<body>
    <button onclick="GetScriptType ();">Get the type of the first script!</button>
    <button onclick="HelloWorld ();">Call HelloWorld function</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content