Javascript Browser Screen colorDepth Property check

Introduction

Display an alternate background color for 8 bit screens:

View in separate window

<!DOCTYPE html>
<html>
<body>

<script>

if (screen.colorDepth <= 8)//w  w  w.j a v  a2  s  . c om
  //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"

</script>

</body>
</html>



PreviousNext

Related