zoukankan      html  css  js  c++  java
  • js读取屏幕长宽

    网页可见区域宽 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

    把以下这段代码放到<head></head>之间或<body></body>之间预览即可看到数据
    <script language="javascript" type="text/javascript">

    width_screen=screen.width;
    height_screen=screen.height;
    availWidth_screen=screen.availWidth;
    availHeight_screen=screen.availHeight;
    colorDepth_screen=screen.colorDepth;


    document.write("你的屏幕宽为:"+width_screen+"<br />你的屏幕高为:"+height_screen+"<br />你的屏幕可用宽为:"+availWidth_screen+"<br />你的屏幕可用高为:"+availHeight_screen+"<br />你的颜色设置所有为数为:"+colorDepth_screen);

    </script>

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

  • 相关阅读:
    指针型函数与函数型指针 -2021.08.04
    Ubuntu18.04 NAT模式下配置静态IP地址 -2020.11.09
    Linux编译内核 Ubuntu18.04 -2020.11.04
    以PING为例,利用Wireshark深入理解网络层、数据链路层的工作原理 -2020.10.30
    Ubuntu18.04虚拟机的安装
    UNIX/Linux系统中的文件属性
    【计算机四级嵌入式】内存管理
    利用预编译解决C/C++重复定义的错误 -2020.09.13
    使用镜像安装cygwin、gcc并配置CLion IDE -2020.09.12
    Android Studio 4.0.1 找不到R.java 2020.09.08
  • 原文地址:https://www.cnblogs.com/jxrichar/p/3906195.html
Copyright © 2011-2022 走看看