screen對象

screen

screen物件表示螢幕的訊息,常用的屬性有:

screen.width:螢幕寬度,以像素為單位;

screen.height:螢幕高度,以像素為單位;

screen.colorDepth:傳回顏色位數,如8、16、24。

<html>
<head>
    <script>
        'use strict';
        alert('Screen size = ' + screen.width + ' x ' + screen.height);
    </script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
document.write("可用高度:" + screen.availHeight);
</script>
</body>
</html>


#
繼續學習
||
<!DOCTYPE html> <html> <body> <h3>Your Screen:</h3> <script> document.write("窗口可以使用的屏幕宽高: "); document.write(window.screen.availWidth + "*" + screen.availHeight); document.write("<br>"); document.write("屏幕的宽高: "); document.write(screen.availWidth + "*" + window.screen.height); document.write("<br>"); document.write("用户浏览器表示的颜色位数: "); document.write(window.screen.colorDepth); document.write("<br>"); document.write("用户浏览器表示的颜色位数(ps:IE不支持?亲测好像支持唉): "); document.write(screen.pixelDepth); </script> <body> </body> </html>
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!