HTML
[javascript] 브라우저별 width,height 구하기

var w = 0, h = 0;

if (typeof (window.innerWidth) == 'number') { //Chrome

     w = window.innerWidth / 2;

     h = window.innerHeight / 2;

} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {

     w = document.documentElement.clientWidth / 2;

     h = document.documentElement.clientHeight / 2;

} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE9

     w = document.body.clientWidth / 2;

     h = document.body.clientHeight / 2;

}

 

출처 : http://ssamkj.tistory.com/3

이 게시물을

공유하기

SEARCH

MENU NAVIGATION