Window screen.colorDepth
Esempio
Ottieni la profondità di bit della tavolozza dei colori:
let depth = screen.colorDepth;
Altri esempi "Provalo da solo" di seguito.
Definizione e utilizzo
La colorDepth
proprietà restituisce la profondità del colore dello schermo.
La colorDepth
proprietà restituisce la profondità in bit per pixel.
La colorDepth
proprietà è di sola lettura.
Sintassi
screen.colorDepth
Valore di ritorno
Tipo | Descrizione |
Un numero | La profondità della tavolozza dei colori dello schermo in bit per pixel: 1, 4, 8, 15, 16, 24, 32 o 48. |
Altri esempi
Visualizza un colore di sfondo alternativo per gli schermi a 8 bit (per evitare che gli schermi a 8 bit, che non supportano il colore moderno, utilizzino invece un brutto colore sostitutivo):
if (screen.colorDepth <= 8)
//simple blue background color for 8 bit screens
document.body.style.background = "#0000FF"
else
//fancy blue background color for modern screens
document.body.style.background = "#87CEFA"
Tutte le proprietà dello schermo:
let text = "Total width/height: " + screen.width + "*" + screen.height + "<br>" +
"Available width/height: " + screen.availWidth + "*" + screen.availHeight + "<br>" +
"Color depth: " + screen.colorDepth + "<br>" +
"Color resolution: " + screen.pixelDepth;
Supporto browser
screen.colorDepth
è supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |