[Project_owners] Textarea behaviour
roman_mir at hotmail.com
Thu Mar 24 03:21:56 EST 2005
I wonder if anyone here knows whether it is possible to set the current
viewport on a textarea?
What I mean is that when I set the value of a textarea to a string that is
longer than the width of the textarea I would like to be able to set the
viewable porition of the string in the textarea.
To make it easier to understand what I mean, when the value of a textarea is
set to a string that contains more lines than there are rows in the
textarea, I can scroll to any line in the textarea to show it with
textarea.scrollTop property (it's clunky, but it works, but I did not find
anything to scroll sideways, to a specific column in the textarea.
The reason why I ask is because in my extension the text that the user is
typing into a textarea is substituted for a different text, so I have to
update the value of the textarea every time the key goes up. But when
textarea.value is set, two things happen: 1. The viewport is reset to the
top of the textarea and 2. The cursor is set after the last character. I
set the cursor position to where it must be with
textarea.setSelectionRange() method, and use textarea.scrollTop to make the
correct line visible. Unfortunately I did not find anything to make a
specific column visible or 'scroll' to it.
More information about the Project_owners