JAVASCRIPT Tutorial
width
, height
, pixelDepth
, and more.screen
Object:const screenObj = window.screen;
console.log("Resolution: " + screenObj.width + " x " + screenObj.height);
console.log("Pixel Depth: " + screenObj.pixelDepth);
console.log("Has Touch: " + ("ontouchstart" in window));
if (screenObj.touchSupport) {
console.log("Touch input supported");
} else {
console.log("Touch input not supported");
}
// Get screen properties and display them
const screenObj = window.screen;
const resolution = screenObj.width + " x " + screenObj.height;
const pixelDepth = screenObj.pixelDepth;
const hasTouch = ("ontouchstart" in window);
console.log("Screen Properties:");
console.log("Resolution: ", resolution);
console.log("Pixel Depth: ", pixelDepth);
console.log("Has Touch: ", hasTouch);