thd/web/js/uc.base.js
changeset 104 8e4fe6f3337d
parent 103 d2af8a210f5d
child 105 c8f710cd1fb1
equal deleted inserted replaced
103:d2af8a210f5d 104:8e4fe6f3337d
     1 var uc = uc || {};
       
     2 
       
     3 //retourne vrai si IE
       
     4 uc.navigatorIsIeNoCollision = function (){
       
     5 return navigator.appName.substring( 0,5 ).toUpperCase() == 'MICRO';
       
     6 }
       
     7 
       
     8 uc.calculeOffsetLeft = function(r){
       
     9 return uc.calculeOffset(r,"offsetLeft")
       
    10 }
       
    11 
       
    12 uc.calculeOffsetTop = function(r){
       
    13 return uc.calculeOffset(r,"offsetTop")
       
    14 }
       
    15 
       
    16 uc.calculeOffset = function(element,attr){
       
    17  var offset=0;
       
    18  while(element){
       
    19    offset+=element[attr];
       
    20    element=element.offsetParent
       
    21  }
       
    22  return offset
       
    23 }
       
    24 
       
    25 
       
    26 uc.returnDocumentSize = function () {
       
    27   var myWidth = 0, myHeight = 0;
       
    28   if( typeof( window.innerWidth ) == 'number' ) {
       
    29     //Non-IE
       
    30     myWidth  = window.innerWidth;
       
    31     myHeight = window.innerHeight;
       
    32   } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
       
    33     //IE 6+ in 'standards compliant mode'
       
    34     myWidth = document.documentElement.clientWidth;
       
    35     myHeight = document.documentElement.clientHeight;
       
    36   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
       
    37     //IE 4 compatible
       
    38     myWidth = document.body.clientWidth;
       
    39     myHeight = document.body.clientHeight;
       
    40   }
       
    41   var result = new Array(myWidth,myHeight);
       
    42   return result;
       
    43 }
       
    44 
       
    45 
       
    46 uc.getDocScrollTop = function(){
       
    47     if(document.body.scrollTop){
       
    48      ltop = document.body.scrollTop;
       
    49     }else{
       
    50      ltop = document.documentElement.scrollTop;
       
    51     }
       
    52 return ltop;
       
    53 }
       
    54 
       
    55 uc.getDocScrollLeft = function(){
       
    56     if(document.body.scrollLeft){
       
    57      ltop = document.body.scrollLeft;
       
    58     }else{
       
    59      ltop = document.documentElement.scrollLeft;
       
    60     }
       
    61 return ltop;
       
    62 }