7. screen 객체

screen은 브라우저가 실행되는 스크린 장치에 관한 정보를 담고 있는 객체이다.

screen 객체는 다음과 같이 접근한다.

window.screen 혹은 screen


* screen 객체의 프로퍼티

availHeight // 작업 표시줄 등을 제외하고 브라우저가 출력 가능한 영역의 높이

availWidth // 작업 표시줄 등을 제외하고 브라우저가 출력 가능한 영역의 폭

pixelDepth // 한 픽셀의 색을 나타내기 위해 사용되는 비트 수

colorDepth // 한 픽셀의 색을 나타내기 위해 사용되는 비트 수로서 pixelDepth와 동일.

대부분의 브라우저에서 지원되므로 pixelDepth보다 colorDepth를 사용할 것을 권함

height // 스크린의 수직 픽셀 수

width // 스크린의 수평 픽셀 수


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>스크린에 관한 정보 출력</title>
<script>
function printScreen() {
    var text = "availHeight:" + screen.availHeight + "<br>";
        text += "availWidth:" + screen.availWidth + "<br>";
        text += "colorDepth:" + screen.colorDepth + "<br>";
        text += "pixelDepth:"    + screen.pixelDepth + "<br>";
        text += "height:" + screen.height + "<br>";
        text += "width:" + screen.width + "<br>";
    document.getElementById("div").innerHTML = text;
}
</script>
</head>
<body onload="printScreen()">
<h3>스크린 장치에 관한 정보</h3>
<hr>
<div id="div"></div>
</body>
</html>
 
cs



Posted by 너래쟁이
: