下面的JS代码通过screen对象获得用户屏幕的相关信息,包括分辨率、颜色数等等
<!DOCTYPE html> <html> <body> <h3>Your Screen:</h3> <script> document.write("Total width/height: "); document.write(screen.width + "*" + screen.height); document.write("<br>"); document.write("Available width/height: "); document.write(screen.availWidth + "*" + screen.availHeight); document.write("<br>"); document.write("Color depth: "); document.write(screen.colorDepth); document.write("<br>"); document.write("Color resolution: "); document.write(screen.pixelDepth); </script> </body> </html>