JavaScript-Referenzhandbuch für Chinesisch
/ JavaScript Window Screen
JavaScript Window Screen
window.screen 對象包含有關(guān)用戶屏幕的信息。
Window Screen
window.screen對象在編寫時可以不使用 window 這個前綴。
一些屬性:
screen.availWidth - 可用的屏幕寬度
screen.availHeight - 可用的屏幕高度
Window Screen 可用寬度
screen.availWidth 屬性返回訪問者屏幕的寬度,以像素計,減去界面特性,比如窗口任務(wù)欄。
實例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> document.write("可用寬度: " + screen.availWidth); </script> </body> </html>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
Window Screen 可用高度
screen.availHeight 屬性返回訪問者屏幕的高度,以像素計,減去界面特性,比如窗口任務(wù)欄。
實例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> document.write("可用寬度: " + screen.availHeight); </script> </body> </html>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例
所有 screen 屬性實例
實例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(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>
運行實例 ?
點擊 "運行實例" 按鈕查看在線實例