Click to See Complete Forum and Search --> : Question about manipulating only highlighted text in a field.


tbroas
07-17-2006, 11:01 AM
Does anyone know of a tutorial that demonstrates how to manipulate only hightlighted text? I'd like to created something similar to the Bold, Italic and Underline buttons used on this forum. For example, if you highlight a word and click the bold icon, the bold tags appear around the text. Is that done strictly with javascript? Thanks in advance!

Exuro
07-17-2006, 01:25 PM
Unfortunately (but not surprisingly) Mozilla and IE browsers don't support the same methods for manipulating text ranges. Here are a few links you might find helpful though:

IE's TextRange object: http://www.webreference.com/js/column12/trmethods.html
DOM Range object (Mozilla): http://www.dotvoid.com/view.php?id=11
Cross-browser text selection example: http://www.teria.com/~koseki/memo/xbselection/