JavaScript ??? ?? ???
/ JavaScript Window Screen
JavaScript Window Screen
window.screen 對(duì)象包含有關(guān)用戶屏幕的信息。
Window Screen
window.screen對(duì)象在編寫時(shí)可以不使用 window 這個(gè)前綴。
一些屬性:
screen.availWidth - 可用的屏幕寬度
screen.availHeight - 可用的屏幕高度
Window Screen 可用寬度
screen.availWidth 屬性返回訪問者屏幕的寬度,以像素計(jì),減去界面特性,比如窗口任務(wù)欄。
實(shí)例
<!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>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
Window Screen 可用高度
screen.availHeight 屬性返回訪問者屏幕的高度,以像素計(jì),減去界面特性,比如窗口任務(wù)欄。
實(shí)例
<!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>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
所有 screen 屬性實(shí)例
實(shí)例
<!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>
運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例