zoukankan      html  css  js  c++  java
  • 关于页面宽高那点事

       
    function getInfo()
    {
     
    //未添加<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">标记情况使用body 否则使用 documentElement
     
    var s = "";
    s += " 网页可见区域宽:"+ parent.document.body.clientWidth; //例如:1360-边框
    s += " 网页可见区域高:" +document.body.clientHeight; //例如:768-123(任务栏 状态栏 地址栏 菜单栏..)
    s += " 网页可见区域宽:" +document.body.offsetWidth+ " (包括边线和滚动条的宽)";
    s += " 网页可见区域高:" +document.body.offsetHeight+ " (包括边线的宽)";
    s += " 网页实际宽:"     + document.body.scrollWidth;  //溢出网页部分也一起计算   clientWidth+溢出部分宽度
    s += " 网页实际高:"      +document.body.scrollHeight;//溢出网页部分也一起计算  clientHeight+溢出部分高度
    s += " 网页被卷去的高(ff):"+ document.body.scrollTop;
    s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop;
    s += " 网页被卷去的左:"+ document.body.scrollLeft;
    s += " 网页正文部分以上:"+ window.screenTop;
    s += " 网页正文部分以左:" +window.screenLeft;
    s += " 屏幕分辨率的高:" +window.screen.height; //例如:768
    s += " 屏幕分辨率的宽:" +window.screen.width; //例如:1360
    s += " 屏幕可用工作区高度:"+ window.screen.availHeight;  //screen.height除去任务栏高度,例如:768-28=738
    s += " 屏幕可用工作区宽度:" +window.screen.availWidth;  //screen.width除去任务栏宽度(任务栏可被拖到屏幕左右两侧)例如:1360-28=1332
    s += " 你的屏幕设置是 " +window.screen.colorDepth+ " 位彩色";
    s += " 你的屏幕设置 " +window.screen.deviceXDPI+ " 像素/英寸";
    alert (s);
    }
    //getInfo();
  • 相关阅读:
    SpringCloud与SpringBoot区别
    Spring cloud概念
    微服务框架对比
    期末作品检查
    管理信息系统 第三部分 作业
    作业38——模型分离(选做)
    作业37——密码保护
    作业36——实现搜索功能
    作业35——完成个人中心—导航标签
    作业34——个人中心标签页导航
  • 原文地址:https://www.cnblogs.com/sparkbj/p/5807878.html
Copyright © 2011-2022 走看看