반응형
window객체는 전역객체로 브라우저상에 일시적으로 공통함수나 값을 공유할 수도 있다.
// window.open("https://www.naver.com", "_blank");
//새창으로 지정된 경로 열기
console.log(window.location.href);
//현재 경로 출력
let width = window.innerWidth;
let height = window.innerHeight;
console.log(`Width: ${width}, Height: ${height}`);
// 윈도의 창 폭과 넓이
브라우저 window객체를 사용하여 현재 창의 url경로를 가져오고 리로딩을 할 수 있다. iframe을 사용할 경우 iframe의 창 폭과 높이가 구해진다.
let width_s = screen.width;
let height_s = screen.height;
console.log(`Width: ${width_s}, Height: ${height_s}`);
screen객체의 폭과 높이를 가져온다. 컴퓨터화면의 폭과 높이를 구한다.
let availWidth = screen.availWidth;
let availHeight = screen.availHeight;
console.log(`Available Width: ${availWidth}, Available Height: ${availHeight}`);
screen객체의 사용가능한 폭과 높이를 가져온다.
반응형
'Javascript' 카테고리의 다른 글
에러 처리 & 디버깅 (0) | 2023.01.24 |
---|---|
Arrow function 화살표함수 (0) | 2023.01.24 |
Class 클래스 (0) | 2023.01.24 |
JSON Object (0) | 2023.01.24 |
Cookie (0) | 2023.01.24 |
댓글