English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Screen colorDepth 属性

JavaScript Screen オブジェクト

colorDepth読み取り専用の属性は、スクリーンの色深度を返します。

colorDepthは、単一のピクセルの色を表すビット数です。

colorDepthは、デバイスのスクリーンがどれだけの色を生成できるかを示します。

例えば、色深度が8のスクリーンは生成できる256色の種類(2 8)。

文法:

screen.colorDepth
var x = "Color Depth: " + screen.colorDepth;
テストを見て‹/›

ブラウザの互換性

すべてのブラウザがcolorDepth属性を完全にサポートしています:

属性
colorDepth

技術的詳細

返り値:画像を表示するためのパレットのビット深度をピクセル単位で示す数字。
可能な値:
  • 各ピクセル1位

  • 各ピクセル4位

  • 各ピクセル8位

  • 各ピクセル15位

  • 各ピクセル16位

  • 各ピクセル24位

  • 各ピクセル32位

  • 各ピクセル48位

さらに多くの例

この例では、すべてのスクリーン属性を表示しています:

var txt = "";
txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight +"</p>";
txt += "<p>Color depth: " + screen.colorDepth + "</p>";
txt += "<p>Color resolution: " + screen.pixelDepth + "</p>";
document.write(txt);
テストを見て‹/›

関連参考

screen 参考情報:screen.availHeight属性

screen 参考情報:screen.availWidth属性

screen 参考情報:screen.height属性

screen 参考情報:screen.width属性

screen 参考情報:screen.pixelDepth属性

JavaScript Screen オブジェクト