zoukankan      html  css  js  c++  java
  • 浏览器常用高宽的JQ插件

    View Code
    /**
     * 兼容BackCompat,CSS1Compat两模式渲染的页面,测试的浏览器 :friefox ie678 chrome opera 
     * @author Lonely 
     
    */
    (function($) {
        
    /**
         * 取得浏览器视图的宽度
         
    */
        $.viewWidth
    =function(){
              
    var w = 0, D=document;
              
    if( D.documentElement &&  D.documentElement.clientWidth ) {
                  w  
    = D.documentElement.clientWidth;
              } 
    else if( D.body &&  D.body.clientWidth ) {
                  w  
    = D.body.clientWidth;
              }
              
    return w ;
        }
        
    /**
         * 取得浏览器视图的高度
         
    */
        $.viewHeight
    =function(){
              
    var h = 0, D=document;
              
    if(document.compatMode!='CSS1Compat'){
                   h 
    = D.body.clientHeight;
              }
    else{
                   
    if( D.documentElement &&  D.documentElement.clientHeight ) {
                    h 
    = D.documentElement.clientHeight;
                  } 
    else if( D.body &&  D.body.clientHeight ) {
                    h 
    = D.body.clientHeight;
                  }
              }
              
    return h;
        }
        
    /**
         * 取得画板的高度(即所有内容,当浏览器内容不足的时候为浏览器视图大小)
         
    */
        $.canvasHeight
    =function(){
            
    var D=document,h=0;
            h
    =Math.max(Math.max(D.body.scrollHeight,D.documentElement.scrollHeight),
                Math.max(D.body.offsetHeight,D.documentElement.offsetHeight),
                Math.max(D.body.clientHeight,D.documentElement.clientHeight)
            );
            
    if($.browser.msie&&$.browser.version>6&&D.body.scrollHeight<$.viewHeight()){
                h
    =D.body.clientHeight;
            }
            
    if($.browser.msie&&document.compatMode=='CSS1Compat'&&D.body.scrollHeight<$.viewHeight()){
                
    if($.browser.version>7&&$.browser.version<9){
                    
                }
    else if($.browser.version>6&&$.browser.version<8){
                
                }
                h
    =D.documentElement.clientHeight;
            }
            
            
    return h;
        }
        
    /**
         * 取得画板的宽度(即所有内容,当浏览器内容不足的时候为浏览器视图大小)
         
    */
        $.canvasWidth
    =function(){
            
    var D=document,w=D.body.scrollWidth;
            
    if(document.compatMode=='CSS1Compat'){
                w
    =D.documentElement.scrollWidth;
            }
    else{
                
    if($.browser.msie&&$.browser.version<=6&&D.body.scrollWidth>$.viewWidth()){
                    w
    =Math.max(Math.max(D.body.scrollWidth,D.documentElement.scrollWidth),
                        Math.max(D.body.offsetWidth,D.documentElement.offsetWidth),
                        Math.max(D.body.clientWidth,D.documentElement.clientWidth)
                    );
                }
            }
            
    return w;
        }
        
    /**
         * 取得画板的宽度(即所有内容,当浏览器内容不足的时候为浏览器视图大小)
         
    */
        $.scrollLeft
    =function(){
            
    if(document.compatMode!='CSS1Compat'||($.browser.msie&&$.browser.version<=6)){
                
    return Math.max($('body').scrollLeft(),document.documentElement.scrollLeft);
            }
    else{
                
    return $('body').scrollLeft();
            }
            
        }
        
    /**
         * 取得画板的宽度(即所有内容,当浏览器内容不足的时候为浏览器视图大小)
         
    */
        $.scrollTop
    =function(){
            
    if (document.compatMode != 'CSS1Compat'||($.browser.msie&&$.browser.version<=6)) {
                
    return Math.max($('body').scrollTop(), document.documentElement.scrollTop);
            }
    else{
                
    return $('body').scrollTop();
            }
        }
    })(jQuery);
  • 相关阅读:
    BFS(双向) HDOJ 3085 Nightmare Ⅱ
    BFS+Hash(储存,判重) HDOJ 1067 Gap
    BFS(判断状态) HDOJ 3533 Escape
    三进制状压 HDOJ 3001 Travelling
    BFS(八数码) POJ 1077 || HDOJ 1043 Eight
    Codeforces Round #332 (Div. 2)
    BFS HDOJ 2102 A计划
    if语句
    shell脚本编程测试类型下
    shell脚本编程测试类型上
  • 原文地址:https://www.cnblogs.com/liushannet/p/1961613.html
Copyright © 2011-2022 走看看