第1章 第884节 dom link type

推荐给朋友

Link type 属性

type 属性可设置或者返回链接文档的类型(MIME 类型) 。

提示: MIME-types 实例: "text/css", "text/javascript", "image/gif", 等。

语法

设置 type 属性:

linkObject.type="MIME-type"

返回 type 属性:

linkObject.type

浏览器支持

所有主要浏览器都支持 type 属性。

在线实例

实例

显示链接文档的 MIME-type:

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

<button type="button" onclick="displayResult()">显示链接元素的 MIME 类型</button>

</body>
</html>

尝试一下