Christopher Finke wrote:
Try: ('number' == typeof x.scrollTop) && (x.scrollTop += 16);
I had thought of this, but this will scroll the textarea whether or not
it would have scrolled in the first place.
Yes.
If I use this method, I'd
need a way to determine if the cursor is currently visible in the
textarea.
Yes, as far as I know a textarea doesn't provide anything that will let
you know that. I can think of a number of ways to do it, but they all
are really hackish. If this is for code, why not copy the text into a
text editor (see below)?
Also, wouldn't the 16 only apply for a certain font size?
Yes. scrollTop is in pixels, so that's all you have. Have you
considered using some element other than a textarea? Unfortunately I
think all the alternatives are browser-specific.
Mozilla: designMode
<URL:http://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla>
IE: contentEditable
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/contenteditable.asp>
mozex: edit textarea content in your choice of text editor:
<URL:http://mozex.mozdev.org/>
There's some helpful stuff here:
<URL:http://ifindkarma.typepad.com/relax/2005/01/life_in_a_texta.html>
Go nuts... :-)
--
Rob