zoukankan      html  css  js  c++  java
  • 关于浏览器的可视大小

    ie6之前的版本,窗口的可视大小body元素的大小。html标记是隐藏的。

    而对于现代浏览器,窗口的可视大小是html元素的大小。html、body元素对应到javascript中分别为document.documentElement、document.body.

    因此ie6以后的版本,ff,safari的可视宽度和高度为:

    var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
    var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;

    opera则以body元素计算窗口的可视大小:

    windowWidth = document.body.clientWidth;
        windowHeight 
    = document.body.clientHeight;

    因此,计算浏览器的可视大小应该表示为:

    var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
    var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;

    //标准下,opera的窗口的可是高度为document.body.clientWidth
    if (window.opera)
    {
        windowWidth 
    = document.body.clientWidth;
        windowHeight 
    = document.body.clientHeight;
    }
  • 相关阅读:
    iOS面试题
    iOS-block
    iOS开发设计模式
    iOS-宏定义
    正则表达式(转)
    iOS-textfield控制光标开始位置
    initWithNibName&initWithCoder &awakeFromNib&UIView常见属性方法
    iOS应用生命周期
    iOS-app发布新版本步骤
    iOS从App跳转至系统设置菜单各功能项
  • 原文地址:https://www.cnblogs.com/wangxiang/p/1258298.html
Copyright © 2011-2022 走看看