By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

IE text range selection

P: n/a
I have a Content Management SYstem that allows users to modify
code/content through a standard "<textarea>" text box. Sometimes, when
they select text (to copy, delete, etc.) they grab on to partial HTML
tags. This causes confusion and messes up the updates they make.

Is there a way to check a selected text range, and if it has a partial
tag selected, to change the selection automatically to the complete tag
or no tag?

Specifically, upon mouseup when a selection is made, check if the
leftmost and rightmost selections include "><", in which case the
selection will be reduced by 1 char (on whichever side) so the partial
tag is not included.

It only needs to work in IE 5.5+. (Intranet with uniform PC setups.)

I have no problem reading selected text, and determining if it contains
partial tags, the problem is in modifying the selected/highlighted text
in the textarea.

Thank you,
A.L.

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ivo
<aq********@gmail.com> wrote
It only needs to work in IE 5.5+. (Intranet with uniform PC setups.)

I have no problem reading selected text, and determining if it contains
partial tags, the problem is in modifying the selected/highlighted text
in the textarea.


Look into the moveStart() and moveEnd() methods of the textrange object. See
(mind the wrap)
<
http://msdn.microsoft.com/workshop/a...hods/movestart.
asp >

hth
--
Ivo


Jul 23 '05 #2

P: n/a
Thanks Ivo, I am giving things a shot based on that link.

If anyone has working code for text ranges using moveStart() and
moveEnd() methods that'd be great!

In the mean time, I will see what I can do on my own...

Thanks,
A.L.
Jul 23 '05 #3

P: n/a
Thanks to Ivo and others I was able to find a working solution. To see
it, follow a thread I started April 1, 2005 in comp.lang.javascript
called:

Changing selected text in textarea

Code samples from Martin Honnen and myself are included in the
thread...

Thanks,
A.L.

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.