J
jackwootton
Hello,
I have a textarea (a very small one). I register a keydown event
listener on the textarea. In the function which handles the event, I
have the following line of code:
self.bc_msg.scrollTop = self.bc_msg.scrollHeight;
This allows the most recent text entered into the textarea to always
be visible. There are issues with using 'self.bc_msg.scrollTop =
self.bc_msg.scrollHeight;', discussed here (http://groups.google.com/
group/comp.lang.javascript/browse_thread/thread/82a8a8ca618b91b1). I
don't understand them fully.
Here's the problem: When a user navigates back through the text
they've entered, they use the arrow keys. This of course triggers the
keydown event, the appropriate function gets called, and the following
line of code is executed: 'self.bc_msg.scrollTop =
self.bc_msg.scrollHeight;'. This means the textarea scrolls to the
bottom as the user is trying to navigate around their previously
entered text.
OK, so I thought I would just detect whether arrow keys were pressed
(inside the event handler), if they were pressed, then I would NOT
execute the code which sets the textarea to display the most recently
entered text. However, if the user proceeds to amend a word, or some
value, then the keydown event will be triggered, and again the
textarea will scroll to the bottom.
Many thanks,
Jack
I have a textarea (a very small one). I register a keydown event
listener on the textarea. In the function which handles the event, I
have the following line of code:
self.bc_msg.scrollTop = self.bc_msg.scrollHeight;
This allows the most recent text entered into the textarea to always
be visible. There are issues with using 'self.bc_msg.scrollTop =
self.bc_msg.scrollHeight;', discussed here (http://groups.google.com/
group/comp.lang.javascript/browse_thread/thread/82a8a8ca618b91b1). I
don't understand them fully.
Here's the problem: When a user navigates back through the text
they've entered, they use the arrow keys. This of course triggers the
keydown event, the appropriate function gets called, and the following
line of code is executed: 'self.bc_msg.scrollTop =
self.bc_msg.scrollHeight;'. This means the textarea scrolls to the
bottom as the user is trying to navigate around their previously
entered text.
OK, so I thought I would just detect whether arrow keys were pressed
(inside the event handler), if they were pressed, then I would NOT
execute the code which sets the textarea to display the most recently
entered text. However, if the user proceeds to amend a word, or some
value, then the keydown event will be triggered, and again the
textarea will scroll to the bottom.
Many thanks,
Jack