savescrollcoordinates help!!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
kuda
Forum Newbie
Posts: 1
Joined: Thu Jun 14, 2007 2:16 pm

savescrollcoordinates help!!

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

JavaScript has a scrollY property that you might be interested in.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post 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 
Post Reply