home *** CD-ROM | disk | FTP | other *** search
/ ftp.novell.com / 2014.06.ftp.novell.com.tar / ftp.novell.com / forge / camtasia.msi / Cabs.w1.cab / ScrollLinks.js < prev    next >
Text File  |  2009-08-17  |  954b  |  42 lines

  1. function ScrollToIndex( DivID, destIndex ) 
  2. {
  3.    var nDestYCoord = destIndex.offsetTop; 
  4.    var thisNode    = destIndex; 
  5.    
  6.    while ( thisNode.offsetParent && ( thisNode.offsetParent !=  document.body) ) 
  7.    { 
  8.       thisNode     = thisNode.offsetParent; 
  9.       nDestYCoord += thisNode.offsetTop; 
  10.    }
  11.  
  12.    nCurWindowYPos = GetCurrentScrollYPos( DivID.id );
  13.  
  14.    //Only scroll if it's needed..
  15.    if( destIndex.offsetTop + destIndex.offsetHeight > DivID.clientHeight )
  16.    {      
  17.       nDestYCoord -= DivID.clientHeight;
  18.       
  19.       if( nDestYCoord > DivID.scrollTop )
  20.       {
  21.          DivID.scrollTop = nDestYCoord;
  22.       }
  23.    }
  24. }
  25.  
  26. function GetCurrentScrollYPos( DivID ) 
  27.    var aDivs = document.body.getElementsByTagName("DIV");
  28.  
  29.    for ( var i=0; i < aDivs.length; i++ ) 
  30.    { 
  31.       var Div = aDivs[i]; 
  32.  
  33.       if ( Div.id == DivID ) 
  34.       { 
  35.          return Div.scrollTop
  36.       }
  37.    }
  38.  
  39.    return 0;
  40. }
  41.