--- title: href slug: Web/API/StyleSheet/href translation_of: Web/API/StyleSheet/href ---
返回当前样式表文件的URI地址.
uri = stylesheet.href
uri 为一个字符串,包含了样式表文件的URI地址. // 在本机环境下
<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>
// 弹出 "file:////C:/Windows/Desktop/example.css
如果该样式表是一个外链样式表文件,则它的href属性值为样式表文件的URI. 但如果该样式表是一个内联样式表,则它的href属性值为null.
该属性在Firefox, Opera, Google Chrome, Safari中为只读属性,在Internet Explorer中可读可写.
{{ languages( {"en": "en/DOM/StyleSheet/href" } ) }}