Screen.pixelDepth

Вы читаете английскую версию этой статьи, так как пока нет перевода на данный язык. Помогите нам перевести эту статью!

Returns the bit depth of the screen. Per the CSSOM, some implementations return 24 for compatibility reasons. See the browser compatibility section for those that don't.

Syntax

let depth = window.screen.pixelDepth

Example

// if there is not adequate bit depth
// choose a simpler color
if ( window.screen.pixelDepth > 8 ) {
  document.style.color = "#FAEBD7";
} else {
  document.style.color = "#FFFFFF";
}

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'Screen.pixelDepth' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
pixelDepthChrome Full support 40
Notes
Full support 40
Notes
Notes Starting with version 59 this property is no longer required to always return 24.
Edge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support 6WebView Android Full support Yes
Notes
Full support Yes
Notes
Notes Starting with version 59 this property is no longer required to always return 24.
Chrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Starting with version 59 this property is no longer required to always return 24.
Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also