468,107 Members | 1,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Highlight text into textarea

Hola boys, i've a question for you!
It's possible to highlight some text inside a textarea? (not all text,
but a portion!)
For example, i've this text inside a textarea.

[ B ] INSERISCI TESTO [ /B ]

i want to highlight only "INSERISCI TESTO".
It, must be an universal function, so i can use it also in other cases,
for example when tag are [ SM ] and [ /SM].
I hope someone can help me, because through internet i find only code IE
compatible e not FIREFOX compatible, and viceversa.
I'd like to have compatibility with both browser.

Thank you so much, for your help.
I'm waiting for you...

tranky
May 16 '06 #1
1 7123
tranky wrote:
Hola boys, i've a question for you!
It's possible to highlight some text inside a textarea? (not all text,
but a portion!)
For example, i've this text inside a textarea.

[ B ] INSERISCI TESTO [ /B ]


In Mozilla/Firefox, you can highlight a single contiguous region in a
textarea via textarea.setSelectionRange(startPos, endPos). The
selection is only visible while the textarea has focus AND before the
textarea first has focus
(https://bugzilla.mozilla.org/show_bug.cgi?id=332424).

In FF, there is a second (manual) way to achieve highlighting in a
textbox, but I have not looked into the possibilities of invoking it
with javascript. To be useful, I would think that it would have to
allow for regular expressions as a specifier: Do a search via ctrl+f.
By https://bugzilla.mozilla.org/show_bug.cgi?id=252371 sought text in
the textarea will not be highlighted. However, if you now press alt+a
you can see all found instances highlighted, including in the
textareas.

If you find javascript access to the presumed highlightAll function, it
would be great if you would post back details. Especially useful would
be the ability to restrict the scope of such a highlightAll function.

Csaba Gabor from Vienna

May 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Doug van Vianen | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.