[thelist] JS for creating html styles/links

Beam sbeam at syxyz.net
Tue Feb 25 12:13:10 CST 2003

> >>It's surprisingly difficult to write a cross-browser script for this. As
> >>far as I know it's not possible, for instance, to find the cursor position
> >>in the textarea in Mozilla.
> >>So in my experience it's not possible to write a cross-browser script.
> >
> >I wondered about whether one could get the selection of a textarea
> >after I sent the mail ... however, would it not be possible to have a
> >textarea and a "preview" section dynamically updated via innerHTML, and
> >find the selection on that?
> Same problem: you can find out which text the selection contains, but not
> where in the textarea or innerHTML the text is located. Of course you could
> try through indexOf(selected string) but if the string is short and common
> ('the ' for instance) this may return the wrong part of the
> textarea.value/innerHTML .
> Forget the JavaScript solution, it simply doesn't (yet) exist.

Well, that may have been true at one time. Gecko now supports a
o.selectionStart, o.selectionEnd, o.setSelectionRange() and o.textLength for
form elements. Which is WAY cool cuz this has been a hangup for a while now.

above works on Moz 1.3b Linux, all Ive tested.
So looks like nothing is stopping us now, right? ;)

More information about the thelist mailing list