From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/stylesheet/href/index.html | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 files/ja/web/api/stylesheet/href/index.html (limited to 'files/ja/web/api/stylesheet/href') diff --git a/files/ja/web/api/stylesheet/href/index.html b/files/ja/web/api/stylesheet/href/index.html new file mode 100644 index 0000000000..b368c0545b --- /dev/null +++ b/files/ja/web/api/stylesheet/href/index.html @@ -0,0 +1,46 @@ +--- +title: StyleSheet.href +slug: Web/API/StyleSheet/href +tags: + - DOM + - Gecko + - Gecko DOM Reference + - StyleSheet +translation_of: Web/API/StyleSheet/href +--- +
+ {{ApiRef}}
+

概要

+

スタイルシートの URI を返します。

+

構文

+
uri = stylesheet.href
+
+ +

+

以下に示す HTML をローカルに配置して表示し、ボタンを押下した場合 file:////C:/Windows/Desktop/example.css などの様な文字列が表示されます。

+
<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="example.css" />
+<script>
+function sref() {
+  alert(document.styleSheets[0].href);
+}
+</script>
+</head>
+
+<body>
+  <button onclick="sref()">alert(document.styleSheets[0].href) を実行</button>
+</body>
+
+</html>
+
+

注記

+

スタイルシートがリンクされたものである場合は、その {{HTMLElement("style")}} 要素の href 属性の示す位置が返ります。インラインスタイルのシートの場合の戻り値は NULL となります。

+

このプロパティは Firefox 、 Opera 、 Google Chrome 、 Safari に於いては読取専用ですが、 Internet Explorer では読取 / 書込ともに可能となっています。

+

仕様書

+ -- cgit v1.2.3-54-g00ecf