Jump to content

ScrollBar

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
How to get current position of scrollbar (X or Y coordinate)?

I use this:

window.scrollTo(0,99999);

var x = (document.all ? document.scrollLeft : window.pageXOffset);

var y = (document.all ? document.scrollTop : window.pageYOffset);

alert("Х = "+Х+" Y = "+Y)

but alert always says X = 0, Y = 0, wherever scrollbar is, what I am do wrong and what I must do for find good coordinates?

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
What browser are you using?
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users