IE text range selection

Discussion in 'Javascript' started by aqualizard@gmail.com, Mar 30, 2005.

  1. Guest

    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.
     
    , Mar 30, 2005
    #1
    1. Advertising

  2. Ivo Guest

    <> 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/author/dhtml/reference/methods/movestart.
    asp >

    hth
    --
    Ivo
     
    Ivo, Mar 30, 2005
    #2
    1. Advertising

  3. A.L. Guest

    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.
     
    A.L., Apr 1, 2005
    #3
  4. Guest

    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.
     
    , Apr 2, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger
    Replies:
    2
    Views:
    16,533
    Christian Kaufhold
    Jan 7, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,479
    Andrew Crowe
    Sep 13, 2004
  3. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    272
    curiousity
    Nov 21, 2003
  4. Loebb
    Replies:
    0
    Views:
    204
    Loebb
    Feb 23, 2004
  5. Replies:
    2
    Views:
    297
Loading...

Share This Page