window.screen对象包含用用屏幕的信息
-
screen.width
返回以像素计的访问者屏幕宽度
document.getElementById("demo").innerHTML = "Screen Width: " + screen.width;
//返回结果是:Screen Width: 1280
-
screen.height
返回以像素计的访问者屏幕的高度
document.getElementById("demo").innerHTML = "Screen Height: " + screen.height;
//返回结果:Screen Height: 720
-
screen.availWidth
返回访问者屏幕的宽度,以像素计,并减去诸如窗口工具条之类的界面特征。
document.getElementById("demo").innerHTML = "Available Screen Width: " + screen.availWidth;
//结果是:Available Screen Width: 1280
-
screen.availHeight
返回访问者屏幕的高度,以像素计,减去诸如窗口工具条之类的界面特征。
document.getElementById("demo").innerHTML = "Available Screen Height: " + screen.availHeight;
//结果是:Available Screen Height: 680
-
screen.colorDepth
返回用于显示一种颜色的比特数,显示以位计的屏幕色彩深度。
所有现代计算机都使用 24 位或 32 位硬件的色彩分辨率:
- 24 bits =16,777,216 种不同的 "True Colors"
- 32 bits = 4,294,967,296 中不同的 "Deep Colors"
document.getElementById("demo").innerHTML = "Screen Color Depth: " + screen.colorDepth;
//结果是:Screen Color Depth: 24
-
screen.pixelDepth
返回屏幕的像素深度
document.getElementById("demo").innerHTML = "Screen Pixel Depth: " + screen.pixelDepth;
//结果是:Screen Pixel Depth: 24
标签:demo,screen,innerHTML,JS,屏幕,document,Screen From: https://www.cnblogs.com/xinbing/p/17004283.html