Link type 属性
![Link 对象参考手册](https://image-10001577.image.myqcloud.com/upload/3/20170423/14929407575092.gif)
定义和用法
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>蜜蜂教程(mifengjc.com)</title> <link id="link1" rel="stylesheet" type="text/css" href="/examples/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>
![Link 对象参考手册](https://image-10001577.image.myqcloud.com/upload/3/20170423/14929407597296.gif)