HTMLLinkElement

HTMLLinkElement interface represents reference information for external resources and the relationship of those resources to a document and vice-versa (corresponds to <link> element; not to be confused with <a> , which is represented by HTMLAnchorElement ). This object inherits all of the properties and methods of the HTMLElement 接口。

特性

Inherits properties from its parent, HTMLElement ,和 LinkStyle .

HTMLLinkElement.as
DOMString representing the type of content being loaded by the HTML link.
HTMLLinkElement.crossOrigin
DOMString that corresponds to the CORS setting for this link element. See CORS settings attributes 了解细节。
HTMLLinkElement.disabled
Boolean which represents whether the link is disabled; currently only used with style sheet links.
HTMLLinkElement.href
DOMString representing the URI for the target resource.
HTMLLinkElement.hreflang
DOMString representing the language code for the linked resource.
HTMLLinkElement.media
DOMString representing a list of one or more media formats to which the resource applies.
HTMLLinkElement.referrerPolicy
DOMString that reflects the referrerpolicy HTML attribute indicating which referrer to use.
HTMLLinkElement.rel
DOMString representing the forward relationship of the linked resource from the document to the resource.
HTMLLinkElement.relList 只读
DOMTokenList that reflects the rel HTML attribute, as a list of tokens.
HTMLLinkElement.sizes 只读
DOMSettableTokenList that reflects the sizes HTML attribute, as a list of tokens.
LinkStyle.sheet 只读
返回 StyleSheet object associated with the given element, or null if there is none.
HTMLLinkElement.type
DOMString representing the MIME type of the linked resource.

过时特性

HTMLLinkElement.charset
DOMString representing the character encoding for the target resource.
HTMLLinkElement.rev
DOMString representing the reverse relationship of the linked resource from the resource to the document.
注意 : Currently the W3C HTML 5.2 spec states that rev is no longer obsolete, whereas the WHATWG living standard still has it labeled obsolete. Until this discrepancy is resolved, you should still assume it is obsolete.
HTMLLinkElement.target
DOMString representing the name of the target frame to which the resource applies.

方法

No specific method; inherits methods from its parent, HTMLElement ,和 LinkStyle .

规范

规范 状态 Comment
Preload 候选推荐 Defines <link rel="preload"> ,和 as property. Note that currently Firefox only supports preloading of cacheable resources.
HTML Living Standard
The definition of 'HTMLLinkElement' in that specification.
实时标准 Adds the following properties: crossOrigin , referrerPolicy ,和 as .
HTML 5.1
The definition of 'HTMLLinkElement' in that specification.
Recommendation
HTML5
The definition of 'HTMLLinkElement' in that specification.
Recommendation The following properties are now obsolete: charset , rev ,和 shape .
The following properties have been added: relList ,和 sizes .
Document Object Model (DOM) Level 2 HTML Specification
The definition of 'HTMLLinkElement' in that specification.
Obsolete Added a second inheritence, the LinkStyle 接口。
Document Object Model (DOM) Level 1 Specification
The definition of 'HTMLLinkElement' in that specification.
Obsolete 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLLinkElement Chrome Yes Edge 12 Firefox 1 IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
as
Chrome 50 Edge 17 Firefox 56 IE Yes Opera 37 Safari Yes WebView Android 50 Chrome Android 50 Firefox Android 56 Opera Android 37 Safari iOS Yes Samsung Internet Android 5.0
crossOrigin
Chrome Yes Edge 17 Firefox 18 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 18 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
referrerPolicy Chrome 51 Edge 79 Firefox 50 IE 不支持 No Opera 38 Safari 11.1 WebView Android 51 Chrome Android 51 Firefox Android 50 Opera Android 41 Safari iOS 不支持 No Samsung Internet Android 5.0
rel Chrome Yes Edge 12 Firefox Yes IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
relList Chrome 54 Edge 17 Firefox 30 IE ? Opera Yes Safari Yes WebView Android 54 Chrome Android 54 Firefox Android 30 Opera Android Yes Safari iOS Yes Samsung Internet Android 6.0
sizes Chrome Yes
注意事项
Yes
注意事项
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Edge 79 Firefox 不支持 No IE ? Opera Yes
注意事项
Yes
注意事项
Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Safari Yes WebView Android Yes
注意事项
Yes
注意事项
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Chrome Android Yes
注意事项
Yes
注意事项
Before Chrome 50, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Firefox Android 不支持 No Opera Android Yes
注意事项
Yes
注意事项
Before Opera 37, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .
Safari iOS Yes Samsung Internet Android Yes
注意事项
Yes
注意事项
Before Samsung Internet 5.0, this property returned the deprecated child DOMSettableTokenList instead of DOMTokenList .

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
见实现注意事项。

另请参阅

  • The HTML element implementing this interface: <link> .
  1. HTMLLinkElement
  2. 特性
    1. as
    2. referrerPolicy
    3. rel
    4. relList
  3. 继承:
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  4. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLElement
    22. HTMLEmbedElement
    23. HTMLFieldSetElement
    24. HTMLFormControlsCollection
    25. HTMLFormElement
    26. HTMLFrameSetElement
    27. HTMLHRElement
    28. HTMLHeadElement
    29. HTMLHeadingElement
    30. HTMLHtmlElement
    31. HTMLIFrameElement
    32. HTMLImageElement
    33. HTMLInputElement
    34. HTMLIsIndexElement
    35. HTMLKeygenElement
    36. HTMLLIElement
    37. HTMLLabelElement
    38. HTMLLegendElement
    39. HTMLMapElement
    40. HTMLMediaElement
    41. HTMLMetaElement
    42. HTMLMeterElement
    43. HTMLModElement
    44. HTMLOListElement
    45. HTMLObjectElement
    46. HTMLOptGroupElement
    47. HTMLOptionElement
    48. HTMLOptionsCollection
    49. HTMLOutputElement
    50. HTMLParagraphElement
    51. HTMLParamElement
    52. HTMLPictureElement
    53. HTMLPreElement
    54. HTMLProgressElement
    55. HTMLQuoteElement
    56. HTMLScriptElement
    57. HTMLSelectElement
    58. HTMLShadowElement
    59. HTMLSourceElement
    60. HTMLSpanElement
    61. HTMLStyleElement
    62. HTMLTableCaptionElement
    63. HTMLTableCellElement
    64. HTMLTableColElement
    65. HTMLTableDataCellElement
    66. HTMLTableElement
    67. HTMLTableHeaderCellElement
    68. HTMLTableRowElement
    69. HTMLTableSectionElement
    70. HTMLTemplateElement
    71. HTMLTextAreaElement
    72. HTMLTimeElement
    73. HTMLTitleElement
    74. HTMLTrackElement
    75. HTMLUListElement
    76. HTMLUnknownElement
    77. HTMLVideoElement
    78. HashChangeEvent
    79. History
    80. ImageData
    81. Location
    82. MessageChannel
    83. MessageEvent
    84. MessagePort
    85. Navigator
    86. NavigatorGeolocation
    87. NavigatorID
    88. NavigatorLanguage
    89. NavigatorOnLine
    90. NavigatorPlugins
    91. PageTransitionEvent
    92. Plugin
    93. PluginArray
    94. PopStateEvent
    95. PortCollection
    96. PromiseRejectionEvent
    97. RadioNodeList
    98. Transferable
    99. ValidityState
    100. Window
    101. WindowBase64
    102. WindowEventHandlers
    103. WindowTimers