该 window.screen对象用于获取用户在JavaScript屏幕信息。以下是JavaScript中window.screen对象的属性。
screen.width-屏幕的宽度
屏幕.height-屏幕高度
screen .availWidth-屏幕宽度,不包括任务栏之类的功能
screen.availHeight-屏幕高度,不包括任务栏之类的功能
您可以尝试运行以下代码以了解如何在JavaScript中使用window.screen对象-
<!DOCTYPE html> <html> <body> <script> document.write("Screen width: " + screen.width); document.write("<br>Screen height: " + screen.height); document.write("<br>Available Screen width: " + screen.availWidth); document.write("<br>Available Screen height: " + screen.availHeight); </script> </body> </html>