Return the MIME-type of the linked document:
var x = document.getElementById("myLink").type;
Click button to return the MIME-type of the linked document.
<!DOCTYPE html> <html> <head> <link id="myLink" rel="stylesheet" type="text/css" href="style.css"> </head>/*from www . java2 s .c o m*/ <body> <h1>I am formatted with a linked style sheet</h1> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myLink").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type property sets or gets the content type (MIME type) of the linked document.
Examples of MIME-types are: "text/css", "text/javascript", "image/gif", etc.
The type property returns a String representing the content type of the linked document.