Javascript Reference - HTML DOM Link type Property








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.

Browser Support

type Yes Yes Yes Yes Yes

Syntax

Return the type property.

linkObject.type 

Set the type property.

linkObject.type=MIME-type

Property Values

Value Description
MIME-type The MIME type of the linked document.




Return Value

A String type value representing the content type of the linked document.

Example

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: