F
Fabien LE LEZ
Hello,
I'd like to put, on a web page, a "place" where the user can type a
rather long text, with automatic coloring of each word (e.g. a color
depending on the number of letters of the word).
The only solution I could think of is rather ugly: a <textarea> for
the user to type in, and behind the <textarea>, one <span> for each
word, with the same text and font, and a colored background.
I've put it there: <http://perso.edulang.com/temp/demo.html>. (For
this demo, the color changes according to whether the number of
letters is even or odd. On this page, the background color changes,
but I'd prefer if the text color would change.)
This solution doesn't really work well: not only did I have a hard
time handling spaces (two consecutive spaces show in a <textarea>, but
are counted as only one in a regular <span>), but also, there are lots
of cases to handle (the scroller for example).
Is there a good and working solution?
Shall I program my own "extented textarea"?
Or maybe Flash would be better in that case?
Thanks a lot in advance...
I'd like to put, on a web page, a "place" where the user can type a
rather long text, with automatic coloring of each word (e.g. a color
depending on the number of letters of the word).
The only solution I could think of is rather ugly: a <textarea> for
the user to type in, and behind the <textarea>, one <span> for each
word, with the same text and font, and a colored background.
I've put it there: <http://perso.edulang.com/temp/demo.html>. (For
this demo, the color changes according to whether the number of
letters is even or odd. On this page, the background color changes,
but I'd prefer if the text color would change.)
This solution doesn't really work well: not only did I have a hard
time handling spaces (two consecutive spaces show in a <textarea>, but
are counted as only one in a regular <span>), but also, there are lots
of cases to handle (the scroller for example).
Is there a good and working solution?
Shall I program my own "extented textarea"?
Or maybe Flash would be better in that case?
Thanks a lot in advance...