下面是一个利用 JavaScript Screen 对象检测用户客户端屏幕信息的实例。对于浏览器不支持的属性,输出值会是 undefined。
<html> <body> <script language="JavaScript"> document.write("<p>屏幕分辨率: ") document.write(screen.width + "*" + screen.height + "</p>") document.write("<p>屏幕可显示面积:") document.write(screen.availWidth + "*" + screen.availHeight + "</p>") document.write("<p>颜色深度: ") document.write(screen.colorDepth + "</p>") document.write("<p>缓冲深度:") document.write(screen.bufferDepth + "</p>") document.write("<p>每英寸水平点数:") document.write(screen.deviceXDPI + "</p>") document.write("<p>每英寸垂直点数:") document.write(screen.deviceYDPI + "</p>") document.write("<p>水平方向的常规点数:") document.write(screen.logicalXDPI + "</p>") document.write("<p>垂直方向的常规点数:") document.write(screen.logicalYDPI + "</p>") document.write("<p>是否启用了字体平滑:") document.write(screen.fontSmoothingEnabled + "</p>") document.write("<p>屏幕的颜色分辨率(比特/像素):") document.write(screen.pixelDepth + "</p>") document.write("<p>屏幕刷新率:") document.write(screen.updateInterval + "</p>") </script> </body> </html>