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.
type |
Yes | Yes | Yes | Yes | Yes |
Return the type property.
linkObject.type
Set the type property.
linkObject.type=MIME-type
Value | Description |
---|---|
MIME-type | The MIME type of the linked document. |
A String type value representing the content type of the linked document.
The following code shows how to get the MIME-type of the linked document.
<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="styles.css">
</head><!--from w w w. j a v a 2 s.com-->
<body>
<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 code above is rendered as follows: