맛집 여행 캠핑 일상 생활

자바스크립트 스크린 및 브라우저 width height 값 알아내기 본문

JAVASCRIPT

자바스크립트 스크린 및 브라우저 width height 값 알아내기

영은파더♥ 2016. 7. 7. 10:03

자바스크립트 스크린 및 브라우저 width height 값 알아내기


모니터 스크린의 가로 세로 사이즈 값은 screen.width height 에서 알아낼 수 있다.

그리고 브라우저의 현재 좌표 값은 window.screenLeft screenTop ( 아래에 top. 을 붙인 이유는 iframe 안에서 알수있게 함이다. )

브라우저의 가로 및 세로 값은 두 종류인데 브라우저 자체의 크기(outerWidth, outerHeight)와 브라우저 안의 크기(innerWidth, innerHeight)가 있다.


<script>

function action_get_wh(event) {

var a = screen.width;

var b = screen.height;

var c = top.window.screenLeft;

var d = top.window.screenTop;

var e = top.window.outerWidth;

var f = top.window.outerHeight;

var g = top.window.innerWidth;

var h = top.window.innerHeight;

var txt = "screen.height : " + a + ", screen.width : " + b + "<br/>";

txt += "top.window.screenLeft : " + c + ", top.window.screenTop : " + d + "<br/>";

txt += "top.window.outerWidth : " + e + ", top.window.outerHeight : " + f + "<br/>";

txt += "top.window.innerWidth : " + g + ", top.window.innerHeight : " + h;

document.getElementById("debug_out").innerHTML = txt;

}

</script>


<button style="border:1px solid red;" onclick="action_get_wh(event)">클릭</button>

<div id="debug_out" style="width:auto;height:200px;border:1px solid red;cursor:pointer;">debug out</div>


테스트 해보세요.


debug out


Trackback : | Comments :