J-Query·JavaS
브라우저 화면 사이즈 구하기
bluemoon527
2021. 9. 30. 23:02
웹 브라우저의 메뉴바와 툴바, 스크롤바 등이 전혀 포함되지 않은 윈도우 내부 영역 크기이다.
window.innerWidth
window.innerHeight
기본크기 + 메뉴바 + 툴바 영역 포함된 크기
$(window).width()
$(window).height()
기본크기 + 메뉴바 + 툴바 + 스크롤바 영역이 포함된 크기
window.outerWidth
window.outerHeight
ex.
$(document).ready(function(){
var size = $(window).width();
if(size < 760){
document.getElementById("link").setAttribute("onClick", "window.open('https://www.naver.com')")
//$("#link").attr("href", "https://www.naver.com")
} else {
document.getElementById("link").setAttribute("onClick", "window.open('https://www.daum.net')")
//$("#link").attr("href", "https://www.daum.net")
};
})
참고
https://jamesyleather.tistory.com/281
[Javascript] 윈도우 창 크기 구하기
윈도우 웹 브라우저로 실행된 창의 크기를 구할 수 있다. 웹 브라우저의 메뉴바와 툴바, 스크롤바 등이 전혀 포함되지 않은 윈도우 내부 영역 크기이다. window.innerWidth window.innerHeight 기본크기 +
jamesyleather.tistory.com