PDA

View Full Version : Tell location of scrollbars in textarea?



glz
06-22-2008, 06:32 PM
I've tried these properties of the textarea element:
offsetHeight
scrollHeight


They effectively tell me when the text has overflowed where it causes there to be scrollbars in the textarea. However, I need to know the location of scrollbars themselves. How can I know where the scrollbar stands in its scrolling range? I have no idea if the user has scrolled halfway down the textarea, not scrolled at all, or when they start to scroll.

How can i tell the location of the scrollbar (width or height) in a textarea?

-thanks http://bstats.freehostia.com/b.gif

magicyte
06-23-2008, 06:48 PM
There wouldn't be any JavaScript-style methods to gain such information. But you can do it manually with a Windows Based Program called Magnifier. If you have windows, search for Magnifier.exe and then open it. If you could open the Internet Explorer file of your little HTML file, you can use magnifier to see how many pixels accross the scrollbar there are, and even how far away from the left it is. It might not be the best way, but it is the only way I know of doing it.

-magicyte

Master_script_maker
06-23-2008, 08:57 PM
returns the distance in pixels from the top of the element to the top of the viewing point: document.getElementById("textarea").scrollTop

glz
06-23-2008, 10:14 PM
thanks everyone... this is a great reference site for all of these methods as well:
http://msdn.microsoft.com/en-us/library/ms533538(VS.85).aspx