Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IE text range selection

Reply
Thread Tools

IE text range selection

 
 
aqualizard@gmail.com
Guest
Posts: n/a
 
      03-30-2005
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.

 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      03-30-2005
<(E-Mail Removed)> 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




 
Reply With Quote
 
 
 
 
A.L.
Guest
Posts: n/a
 
      04-01-2005
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.
 
Reply With Quote
 
aqualizard@gmail.com
Guest
Posts: n/a
 
      04-02-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE Selection/Range: Set range start at the click position, get char offset adamjroth@gmail.com Javascript 2 04-09-2007 04:02 AM
JTable with row selection, but no cell selection Simon Niederberger Java 2 01-07-2005 04:17 PM
JS comparing innerHTML to text selection (window.getSelection() /document.selection) Andrew Crowe HTML 1 09-13-2004 02:22 PM
How to change a range selection to text selection? Loebb Javascript 0 02-23-2004 02:12 PM
HOWTO autopost the selection list upon selection curiousity ASP .Net Mobile 0 11-21-2003 12:57 AM



Advertisments