Page 1 of 1

savescrollcoordinates help!!

Posted: Thu Jun 14, 2007 2:20 pm
by kuda
Hey everyone.

I am fixing up my website and I am trying to save the scroll coordinates when the website loads at half way of the 1000px (example) web page. I would also like to know if I locked my scrollbar, would it lock it at that position??

What is the exact code that I use? The website file is test.html.

Thank you for any help!!

Here is what I am looking for (approximately): http://img239.imageshack.us/img239/6996/scollcz1.jpg

Posted: Thu Jun 14, 2007 3:20 pm
by superdezign
JavaScript has a scrollY property that you might be interested in.

Posted: Fri Jun 15, 2007 3:31 am
by Gente

Code: Select all

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    //FF compliant
    scrOfY = window.pageYOffset;
  } 
  else if( document.body && document.body.scrollTop) 
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } 
  else if( document.documentElement && document.documentElement.scrollTop) 
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function yourFunction()
{
  ............
}

// Determination of scroll
window.onscroll = yourFunction