zoukankan      html  css  js  c++  java
  • 关于javascript js获取各种浏览器可见窗口大小

    Js代码  收藏代码
    1. function getInfo()  
    2. {  
    3.     var s = "";  
    4.     s += " 网页可见区域宽:"+ document.body.clientWidth;  
    5.     s += " 网页可见区域高:"+ document.body.clientHeight;  
    6.     s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)";  
    7.     s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)";  
    8.     s += " 网页正文全文宽:"+ document.body.scrollWidth;  
    9.     s += " 网页正文全文高:"+ document.body.scrollHeight;  
    10.     s += " 网页被卷去的高(ff):"+ document.body.scrollTop;  
    11.     s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop;  
    12.     s += " 网页被卷去的左:"+ document.body.scrollLeft;  
    13.     s += " 网页正文部分上:"+ window.screenTop;  
    14.     s += " 网页正文部分左:"+ window.screenLeft;  
    15.     s += " 屏幕分辨率的高:"+ window.screen.height;  
    16.     s += " 屏幕分辨率的宽:"+ window.screen.width;  
    17.     s += " 屏幕可用工作区高度:"+ window.screen.availHeight;  
    18.     s += " 屏幕可用工作区宽度:"+ window.screen.availWidth;  
    19.     s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色";  
    20.     s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸";  
    21.     alert (s);  
    22. }  
    23. getInfo();  
    24. </script>  



    如果没有声明W3C标准: 

    Html代码  收藏代码
    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    表达式 IE FF或Opera
    document.body.clientWidth 可见区域宽度 可见区域宽度
    document.body.clientHeight 可见区域宽度 可见区域高度
    document.documentElement.clientWidth 0 页面对象宽度(即BODY对象宽度加上Margin宽)
    document.documentElement.clientHeight 0 页面对象高度(即BODY对象高度加上Margin高)



    如果声明了W3C标准: 

    表达式 IE或FF Opera
    document.body.clientWidth BODY对象宽度 可见区域宽度
    document.body.clientHeight BODY对象高度 可见区域高度
    document.documentElement.clientWidth 可见区域宽度 页面对象宽度(即BODY对象宽度加上Margin宽)
    document.documentElement.clientHeight 可见区域高度 页面对象高度(即BODY对象高度加上Margin高)
  • 相关阅读:
    linux查看cpu、内存信息
    PHP之路,Day1
    Zabbix3.0完整部署
    linux时间同步
    nginx日志切割脚本
    Rsync+sersync文件实时同步
    阿里云自动挂载云盘脚本
    nginx不支持pathinfo 导致thinkphp出错解决办法
    VIM选项配置说明
    vagrant 本地添加box 支持带版本号
  • 原文地址:https://www.cnblogs.com/newsouls/p/2746046.html
Copyright © 2011-2022 走看看