Get the MIME type of a script:
var x = document.getElementById("myScript").type
Click the button to return the value of the type attribute of the script.
<!DOCTYPE html> <html> <body> <script id="myScript" type="text/javascript"> document.write("Hello World!"); </script>//w ww . java 2s.c o m <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 type property sets or gets the value of the type attribute of a script.
The type attribute sets the MIME type of a script.
For JavaScript, the MIME type is "text/javascript".
Some common values:
text/javascript
(this is default) text/ecmascript
application/ecmascript
application/javascript
The type property accepts and returns a boolean type value.