IE text range selection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • aqualizard@gmail.com

    #1

    IE text range selection

    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.

  • Ivo

    #2
    Re: IE text range selection

    <aqualizard@gma il.com> wrote[color=blue]
    > 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.
    >[/color]

    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




    Comment

    • A.L.

      #3
      Re: IE text range selection

      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.

      Comment

      • aqualizard@gmail.com

        #4
        Re: IE text range selection

        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.javas cript
        called:

        Changing selected text in textarea

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

        Thanks,
        A.L.

        Comment

        Working...