윈도우 객체


* 윈도우 창크기 변동 이벤트 예: 창 크기를 변경해보세요..

윈도우 가로 너비: , 윈도우 세로 높이:

                                
                                    
                                
                            
                                
                                    const width= document.querySelector('#width_info')
                                    const height= document.querySelector('#height_info')

                                    function onResize() {
                                        width.innerText= `${window.innerWidth}px`;
                                        height.innerText= `${window.innerHeight}px`;
                                    }

                                    let resizeTimer
                                    window.addEventListener('resize', () => { // 윈도우 사이즈가 변경될 때마다
                                        if (resizeTimer != null) clearTimeout(resizeTimer) // 시스템에 부하를 줄 경우에 대한 대비

                                        resizeTimer= setTimeout(() => {
                                            onResize()
                                        }, 1000); // 1초 후에 작업을 수행한다!
                                    })