본문 바로가기

Programming/JavaScript

Window Resizing

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Events</title>
</head>
<body>
    <h1>Resize the Window and Watch the Console</h1>

    <script>

        window.addEventListener('resize', function(){

            console.log(`The window width is ${window.innerWidth}`);
            console.log(`The window height is ${window.innerHeight}`);
        });

    </script>
</body>
</html>

윈도우 사이즈를 조절하면 높이와 너비가 콘솔에 찍힘

'Programming > JavaScript' 카테고리의 다른 글

Hello World!  (0) 2022.07.07
Key Down Event  (0) 2022.03.11
Capturing Scroll Events  (0) 2022.03.11
Mouseover, Mouseover Events: HTMLPreviousNext  (0) 2022.03.11
Event.preventDefault()  (0) 2022.03.11