JavaScript Window Screen
The window.screen object contains information about the user's screen.
Window Screen
window.screenThe object can be written without the window prefix.
Some properties:
screen.availWidth - available screen width
- ##screen.availHeight - available screen height
Window Screen Available Width The screen.availWidth property returns the width of the visitor's screen, in pixels, minus interface features such as the window taskbar.
Instance
Run Instance»Click the "Run Instance" button to view the online instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <script> document.write("可用宽度: " + screen.availWidth); </script> </body> </html>
Run Instance»Click the "Run Instance" button to view the online instance
Window Screen Available HeightThe screen.availHeight property returns the height of the visitor's screen, in pixels, minus interface features such as the window taskbar.
Instance
Run Instance»Click the "Run Instance" button to view the online instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <script> document.write("可用宽度: " + screen.availHeight); </script> </body> </html>
Run Instance»Click the "Run Instance" button to view the online instance
All screen attribute instances
Instance
Run instance»Click" Run Instance" button to view the online instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <h3>你的屏幕:</h3> <script> document.write("总宽度/高度: "); document.write(screen.width + "*" + screen.height); document.write("<br>"); document.write("可用宽度/高度: "); document.write(screen.availWidth + "*" + screen.availHeight); document.write("<br>"); document.write("色彩深度: "); document.write(screen.colorDepth); document.write("<br>"); document.write("色彩分辨率: "); document.write(screen.pixelDepth); </script> </body> </html>
Run instance»Click" Run Instance" button to view the online instance