I hope this isn't too terribly off topic, since the actual
problem is a Firefox bug, but perhaps it will be of interest
to other Firefox/jQuery users. I am using a very simple
jQuery script to input unusual characters. It simply runs a
bunch of substitutions on the .value of a textarea on every
.keyup(). Here's a test:
It works fine, but if the text is too long to fit in the
textarea, it automatically scrolls back to the top after
every keyup -- that is, every time the textarea's .value is
reset. This is a known bug in
But it ain't pretty. Perhaps someone here has dealt with
this bug, or has an idea for a better workaround?
The scrolling workaround in that page is just these two lines of code:
var scrollTop = txtarea.scrollTop;
/* change text and set new selection here */
txtarea.scrollTop = scrollTop;
I don't see how it could get any simpler than that - save the scroll
position before changing the text, restore it after.
have anyway - replacing the selected text, setting the new selection, etc.
You don't need to replace your existing code to implement the workaround,
just save and restore scrollTop at the right place.