
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Pixel Depth and Color Depth of a Screen in JavaScript
Javascript window object has provided many methods to get various kinds of information regarding the browser. It has provided screen.colorDepth and screen.pixelDepth to get the color depth and pixel depth of browser screen respectively. Let's discuss them individually.
Color depth
The window object has provided screen.colorDepth method to return the color depth. Color depth is nothing but the number of bits used to display one color. All modern computers use 24 bit or 32 bit hardware for color resolution.
Example
<html> <body> <p id="depth"></p> <script> document.getElementById("depth").innerHTML = "Screen color depth is " + screen.colorDepth; </script> </body> </html>
Output
Screen color depth is 24
Pixel depth
Javascript window object has provided screen.pixelDepth to return the pixel depth of the browser screen.
Example
<html> <body> <p id="depth"></p> <script> document.getElementById("depth").innerHTML = "Screen pixel depth is " + screen.pixelDepth; </script> </body> </html>
Output
Screen pixel depth is 24
Advertisements