• 网页宽度高度获取方法备忘


    function gets()
    {
    var s ="网页可见区域宽:"+ document.body.clientWidth;
    s += "<br>网页可见区域高:" + document.body.clientHeight;
    s += "<br>网页可见区域宽:" + document.body.offsetWidth +" (包括边线的宽)";
    s += "<br>网页可见区域高:" + document.body.offsetHeight +" (包括边线的宽)";
    s += "<br>网页正文全文宽:" + document.body.scrollWidth;
    s += "<br>网页正文全文高:" + document.body.scrollHeight;
    s += "<br>网页被卷去的高:" + document.body.scrollTop;
    s += "<br>网页被卷去的左:" + document.body.scrollLeft;
    s += "<br>网页正文部分上:" + window.screenTop;
    s += "<br>网页正文部分左:" + window.screenLeft;
    s += "<br>屏幕分辨率的宽:" + window.screen.width;
    s += "<br>屏幕分辨率的高:" + window.screen.height;
    s += "<br>屏幕可用工作区宽度:" + window.screen.availWidth;
    s += "<br>屏幕可用工作区高度:" + window.screen.availHeight;
    document.getElementById('dd').innerHTML = s;
    }

    你可以参考下面这个函数,这个函数是获取完整页面尺寸的函数(即你说的浏览器能看到的区域,不包括被滚动条卷去的区域)
    -----------------------------js代码---------------------------------------------------------
    <script>
    function GetPageSize(){
        var xScroll, yScroll;
        if (window.innerHeight  &&  window.scrollMaxY) { 
            xScroll = document.body.scrollWidth;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        var windowWidth, windowHeight;
        if (self.innerHeight) {
            windowWidth = self.innerWidth;
            windowHeight = self.innerHeight;
        } else if (document.documentElement  &&  document.documentElement.clientHeight) {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) {
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        } 
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else { 
            pageHeight = yScroll;
        }
        if(xScroll < windowWidth){ 
            pageWidth = windowWidth;
        } else {
            pageWidth = xScroll;
        }
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
        return arrayPageSize;
    }
    alert(GetPageSize());
    </script>
    
  • 相关阅读:
    poj 2488 DFS
    畅通工程 并查集模版
    KMP 模板
    poj 1426 DFS
    poj 2528 线段数
    poj 3468 线段数 修改区间(点)
    CVPR2012文章阅读(2)A Unified Approach to Salient Object Detection via Low Rank Matrix Recovery
    如何制定目标
    Saliency Map 最新综述
    计算机视觉模式识别重要会议杂志
  • 原文地址:https://www.cnblogs.com/nanfei/p/3282553.html
Copyright © 2020-2023  润新知