diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/stylesheet/media/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/ja/web/api/stylesheet/media/index.html')
-rw-r--r-- | files/ja/web/api/stylesheet/media/index.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/files/ja/web/api/stylesheet/media/index.html b/files/ja/web/api/stylesheet/media/index.html new file mode 100644 index 0000000000..6c3de44d29 --- /dev/null +++ b/files/ja/web/api/stylesheet/media/index.html @@ -0,0 +1,57 @@ +--- +title: StyleSheet.media +slug: Web/API/StyleSheet/media +tags: + - API + - CSSOM + - Media + - StyleSheet + - プロパティ +translation_of: Web/API/StyleSheet/media +--- +<div>{{APIRef("CSSOM")}}</div> + +<p><strong>StyleSheet.media</strong> は、スタイル情報の対象として想定するメディアを指定します。これは読み取り専用で配列風の <code>MediaList</code> オブジェクトであり、 <code>deleteMedium()</code> で削除したり <code>appendMedium()</code> で追加したりすることができます。</p> + +<h2 id="Example" name="Example">例</h2> + +<pre><!doctype html> +<html> +<head> +<link rel="stylesheet" href="document.css" type="text/css" media="screen" /> +<style rel="stylesheet" type="text/css" media="screen, print"> +body { background-color: snow; } +</style> +</head> +<body> + +<script> +for (var iSheetIndex = 0; iSheetIndex < document.styleSheets.length; iSheetIndex++) + { + console.log('document.styleSheets[' + String(iSheetIndex) + '].media: ' + + JSON.stringify(document.styleSheets[iSheetIndex].media)); + if (iSheetIndex === 0) + document.styleSheets[iSheetIndex].media.appendMedium('handheld'); + if (iSheetIndex === 1) + document.styleSheets[iSheetIndex].media.deleteMedium('print'); + console.log('document.styleSheets[' + String(iSheetIndex) + '].media: ' + + JSON.stringify(document.styleSheets[iSheetIndex].media)); + } +/* +will log: +document.styleSheets[0].media: {"0":"screen"} +document.styleSheets[0].media: {"0":"screen","1":"handheld"} +document.styleSheets[1].media: {"0":"screen","1":"print"} +document.styleSheets[1].media: {"0":"screen"} +*/ +</script> + +</body> +</html> +</pre> + +<h2 id="Specification" name="Specification">仕様書</h2> + +<p>DOM Level 2 Styles - STYLESHEET</p> + +<p><a href="https://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-MediaList">W3C: Document Object Model Style Sheets - MediaList</a></p> |