1. 程式人生 > >通過Js來獲取所有螢幕解析度的總結

通過Js來獲取所有螢幕解析度的總結

通過Js來獲取所有螢幕適配的總結

<script type="text/javascript">

    window.onload=function(){
    //document.getElementById("test").style.height="200px";
    //document.getElementsByTagName('div')[0].offsetHeight='600px';
    document.getElementsByTagName('div')[0].style.height=document.body.clientHeight+'px';
        //alert(document.getElementsByTagName('div')[0].offsetHeight=document.body.clientHeight);

        //alert(document.body.clientHeight);
    };
</script>

<html>
<script>
function a(){
document.write(
"螢幕解析度為:"+screen.width+"*"+screen.height

"螢幕可用大小:"+screen.availWidth+"*"+screen.availHeight

"網頁可見區域寬:"+document.body.clientWidth

"網頁可見區域高:"+document.body.clientHeight

"網頁可見區域寬(包括邊線的寬):"+document.body.offsetWidth


"網頁可見區域高(包括邊線的寬):"+document.body.offsetHeight

"網頁正文全文寬:"+document.body.scrollWidth

"網頁正文全文高:"+document.body.scrollHeight

"網頁被捲去的高:"+document.body.scrollTop

"網頁被捲去的左:"+document.body.scrollLeft

"網頁正文部分上:"+window.screenTop

"網頁正文部分左:"+window.screenLeft
"螢幕解析度的高:"+window.screen.height

"螢幕解析度的寬:"+window.screen.width


"螢幕可用工作區高度:"+window.screen.availHeight

"螢幕可用工作區寬度:"+window.screen.availWidth
);
}
</script>
<body onload="a()" >
</body>
</html>