Link typeProperty

Link 对象参考手册Link Object

Definition and Usage

The type property sets or returns the type (MIME type) of the linked document.

Tip:MIME type examples: "text/css", "text/javascript", "image/gif", etc.

Syntax

Set the type property:

linkObject.type="MIME-type"

Return the type property:

linkObject.type


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the type property


Examples

Examples

Display the MIME type of the linked document:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<link id="link1" rel="stylesheet" type="text/css" href="style1.css.html">
<script>
function displayResult(){
    var x=document.getElementById("link1").type;
    alert(x);
}
</script>
</head>
<body>

<button type="button" onclick="displayResult()">Display the MIME type of the link element</button>

</body>
</html>

Try it yourself »


Link 对象参考手册Link Object Other Extensions