atom feed3 messages in com.googlegroups.jquery-en[jQuery] Dealing with Firefox textare...
FromSent OnAttachments
Patrick HallJun 27, 2006 3:23 am 
Michael GearyJun 27, 2006 8:29 am 
Patrick HallJun 27, 2006 11:54 am 
Subject:[jQuery] Dealing with Firefox textarea bug? (somewhat off topic)
From:Michael Geary (
Date:Jun 27, 2006 8:29:20 am

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 Firefox:

There is a workaround in that thread:

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.

The rest of the JavaScript code on that test page corresponds to code you'd 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.