The type
attribute specifies the MIME type of a script.
The type
property sets or gets the type attribute of a script.
type |
Yes | Yes | Yes | Yes | Yes |
Return the type property.
var v = scriptObject.type
Set the type property.
scriptObject.type=MIME_type
Value | Description |
---|---|
MIME_type | Specifies the MIME type of the script. Some common values:
|
A String type value representing the MIME type of the script.
The following code shows how to get the MIME type of a script.
<!DOCTYPE html>
<html>
<body>
<!--from www .ja va2s . c o m-->
<script id="myScript" type="text/javascript">
document.write("Hello World!");
</script>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myScript").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: