Tuesday, 28 June 2011

check scrollbars exists in a control though JavaScript

function IsScrollBarExist(Object,Aces)
{
      if(!Aces){
            Aces = "either x or y";
      }
      switch (Aces)
      {
            case 'x' :
                  Object.scrollLeft=1;
                  if (Object.scrollLeft>0) {Object.scrollLeft=0; return true;}
                  else {return false;}
                  break;
            case 'y' :
                  Object.scrollTop=1;
                  if (Object.scrollTop>0) {Object.scrollTop=0; return true;}
                  else {return false;}
                  break;
            case 'xy' :
                  Object.scrollTop=1;
                  Object.scrollLeft=1;           
                  if (Object.scrollTop>0 && Object.scrollLeft>0) {Object.scrollTop=0; Object.scrollLeft=0; return true;}
                  else {return false;}
                  break;
            default :
                  Object.scrollTop=1;
                  Object.scrollLeft=1;           
                  if (Object.scrollTop>0 || Object.scrollLeft>0) {Object.scrollTop=0; Object.scrollLeft=0; return true;}
                  else {return false;}
                  break;
      }       
}

No comments:

Post a Comment