question relating to document.selection

Discussion in 'Javascript' started by c.anandkumar@gmail.com, Mar 14, 2005.

  1. Guest

    Hi
    How do I figure out if a selection in a document is in a particular
    control?
    I have a TEXTAREA in which a user can type in some text, select some
    text and 'apply' tags around it clicking a button. I am using
    document.selection.createRange() to create a textRange object and then
    modify its text property to suit the action. But the problem is I want
    to limit this action to a few "INPUT type=text" and TEXTAREA controls.

    How do I check if the selection is made in one of a set of controls?
    Thanks for your help
    Anand
     
    , Mar 14, 2005
    #1
    1. Advertising

  2. wrote:


    > How do I figure out if a selection in a document is in a particular
    > control?
    > I have a TEXTAREA in which a user can type in some text, select some
    > text and 'apply' tags around it clicking a button. I am using
    > document.selection.createRange() to create a textRange object and then
    > modify its text property to suit the action. But the problem is I want
    > to limit this action to a few "INPUT type=text" and TEXTAREA controls.
    >
    > How do I check if the selection is made in one of a set of controls?


    var range = document.selection.createRange();
    var textarea = document.forms.formName.elements.textareaName;
    if (range.parentElement() = textarea) {
    ...
    }
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Mar 14, 2005
    #2
    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. Chipmunk
    Replies:
    2
    Views:
    322
    Eric Lawrence [MSFT]
    Feb 23, 2004
  2. Leo
    Replies:
    13
    Views:
    593
    James McGill
    Feb 28, 2006
  3. Andrew Crowe
    Replies:
    1
    Views:
    4,535
    Andrew Crowe
    Sep 13, 2004
  4. Jon Bosker
    Replies:
    6
    Views:
    394
    Jon Bosker
    Sep 29, 2003
  5. Abraham Vionas
    Replies:
    1
    Views:
    144
    Edwin Eyan Moragas
    Nov 30, 2004
Loading...

Share This Page