• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>JavaScript BOM Window Object</title>
7
</head>
8
​
9
<body>
10
​
11
    <h1>브라우저 창 크기 조절</h1>
12
    <p>웹 브라우저의 창 크기를 조절한 뒤에 결과보기를 다시 눌러보세요!</p>
13
​
14
    <script>
15
        var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
16
        var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
17
​
18
        document.write("웹 브라우저의 너비는 " + windowWidth + "픽셀이고, 높이는 " + windowHeight + "픽셀입니다.");
19
    </script>
20
    
21
</body>
22
​
23
</html>