href
特性为
StyleSheet
interface returns the location of the style sheet.
uri = stylesheet.href
uri
is a string containing the stylesheet's URI.
// on a local machine:
<html>
<head>
<link rel="StyleSheet" href="example.css" type="text/css" />
<script>
function sref() {
alert(document.styleSheets[0].href);
}
</script>
</head>
<body>
<div class="thunder">Thunder</div>
<button onclick="sref()">ss</button>
</body>
</html>
// returns "file:////C:/Windows/Desktop/example.css
If the style sheet is a linked style sheet, the value of its attribute is its location. For inline style sheets, the value of this attribute is
NULL
.
This property is read-only in Firefox, Opera, Google Chrome, and Safari, and it is read/write in Internet Explorer.
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Object Model (CSSOM)
The definition of 'StyleSheet: href' in that specification. |
工作草案 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
href
|
Chrome 1 | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
兼容性未知
StyleSheet
AnimationEvent
CSS
CSSConditionRule
CSSGroupingRule
CSSKeyframeRule
CSSKeyframesRule
CSSMediaRule
CSSNamespaceRule
CSSPageRule
CSSRule
CSSRuleList
CSSStyleDeclaration
CSSStyleRule
CSSStyleSheet
CSSSupportsRule
CaretPosition
LinkStyle
MediaQueryList
MediaQueryListListener
Screen
StyleSheetList
TransitionEvent