目录

HTML DOM link 对象


链接对象

Link 对象表示 HTML <link> 元素。

访问链接对象

您可以使用 getElementById() 访问 <link> 元素:

示例

var x = document.getElementById("myLink");
亲自试一试 »

创建链接对象

您可以使用 document.createElement() 方法创建 <link> 元素:

示例

var x = document.createElement("LINK");
亲自试一试 »

链接对象属性

Property Description
charset Not supported in HTML5.
Sets or returns the character encoding of the linked document
crossOrigin Sets or returns the the CORS settings of the linked document
disabled Sets or returns whether the linked document is disabled, or not
href Sets or returns the URL of the linked document
hreflang Sets or returns the language code of the linked document
media Sets or returns the media type for the link element
rel Sets or returns the relationship between the current document and the linked document
rev Not supported in HTML5.
Sets or returns the reverse relationship from the linked document to the current document
sizes Returns the value of the sizes attribute of the linked resource
type Sets or returns the content type of the linked document

标准属性和事件

Link 对象还支持标准特性事件


相关页面

HTML 参考:HTML <链接> 标签