swneng

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

      SDocument = new Object();
     SDocument.getDocument = function(){
                                  if(document.compatMode=="CSS1Compat"){
                                       return document.documentElement;
                                  }
                                  else{
                                       return document.body;
                                  }
                             }
     SDocument.getRectangle = function (){
                                    if(window.innerWidth){
                                       return [window.innerWidth,window.innerHeight];
                                    }
                                    else{
                                          if(document.compatMode=="CSS1Compat"){
                                               return [document.documentElement.clientWidth,document.documentElement.clientHeight];
                                          }
                                          else{
                                               return [document.body.clientWidth,document.body.clientHeight];
                                          }
                                    }
                               }
     SDocument.getViewportRectangle =function(){
                                              if(document.compatMode=="CSS1Compat"){
                                                   return [document.documentElement.scrollWidth,document.documentElement.scrollHeight];
                                              }
                                              else{
                                                   return [document.body.scrollWidth,document.body.scrollHeight];
                                              } 
                                     }
     SDocument.getWidth = function (){
                                    var w = SDocument.getViewportRectangle();
                                    return Math.max(w[0],SDocument.getWidth());  
                          }
     SDocument.getHeight =function(){
                                        var h =SDocument.getViewportRectangle();
                                        return h[1];
                          }
     SDocument.getScrollLeft =function(){  
                                   return parseInt(SDocument.getDocument().scrollLeft);
                              }
     SDocument.getScrollTop = function(){
                                   return parseInt(SDocument.getDocument().scrollTop);
                                   }
     SDocument.getViewportWidth =function(){
                                          var w=SDocument.getRectangle();
                                          return parseInt(w[0]);
                                 }
     SDocument.getViewportHeight =function(){
                                          var h=SDocument.getRectangle();
                                          return parseInt(h[1]);
                                 }
                                 
                                

posted on 2008-10-06 17:32  易哲  阅读(258)  评论(0编辑  收藏  举报