您的位置:首页 > Web前端 > JavaScript

javascript获取浏览器的宽度和高度

2009-10-23 14:54 411 查看
<script language="JavaScript" type="text/JavaScript">
<!--
        function displayScreenSize()
        {
            var bodyWidth           =document.body.clientWidth;               //网页可见区域宽

            var bodyHeight          =document.body.clientHeight;              //网页可见区域高

            var bodyWidthWithBorder =document.body.offsetWidth;      //网页可见区域宽(包括边线的宽)

            var bodyHeightWithBorder=document.body.offsetHeight;     //网页可见区域高(包括边线的宽)

            var bodyWidthWithScroll =document.body.scrollWidth;         //网页正文全文宽

            var bodyHeightWithScroll=document.body.scrollHeight;        //网页正文全文高 

            var bodyTopHeight       =document.body.scrollTop;               //网页被卷去的上边距

            var bodyLeftWidth       =document.body.scrollLeft;               //网页被卷去的左边距

            var windowTopHeight     =window.screenTop;                     //网页正文部分上边距

            var windowLeftWidth     =window.screenLeft;                     //网页正文部分左边距

            var screenHeight        =window.screen.height;                    //屏幕分辨率的高

            var screenWidth         =window.screen.width;                     //屏幕分辨率的宽

            var screenAvailHeight   =window.screen.availHeight;          //屏幕可用工作区高度

            var screenAvailWidth    =window.screen.availWidth;           //屏幕可用工作区宽度

        }
-->
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息