Link type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Link

Description

The type property sets or gets the MIME type of the linked document.

Examples of MIME-types are: "text/css", "text/javascript", "image/gif", etc.

Set the type property with the following Values

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

Return Value

A String, representing the content type of the linked document

The following code shows how to return the MIME-type of the linked document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="styles.css">
</head>// w w  w . ja  v  a2  s  .  c o  m
<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>

Related Tutorials