JAVASCRIPT SCREEN OBJECT

Lavanya



JavaScript Screen Object 

The JavaScript `screen` object provides information about the browser's screen, such as its width, height, color depth, and pixel depth, which can be useful for display purposes.

The `Screen` object is a property of the `window`, meaning it can be accessed using:

`window.Screen`

Or

`Screen`

Property of JavaScript Screen Object 


The `screen` object has several properties that provide information about the browser's display.



Example of JavaScript Screen Object 


Here are various ways the screen object can be used.

<Script>


console.log("Screen Information:");
console.log("Width:", screen.width);
console.log("Height:", screen.height);
console.log("Avail Width:", screen.availWidth);
console.log("Avail Height:", screen.availHeight);
console.log("Color Depth:", screen.colorDepth);
console.log("Pixel Depth:", screen.pixelDepth);
console.log("Device DPI:", screen.deviceXDPI, "x", screen.deviceYDPI);

</Script>


Output:

Screen Information:
Width: 1920
Height: 1080
Avail Width: 1920
Avail Height: 1040
Color Depth: 24
Pixel Depth: 24
Device DPI: 96 x 96


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send