Javascript text replacement

Discussion in 'JavaScript' started by Rogare, Feb 20, 2008.

  1. #1
    I am making a "text editor" of HTML (doesn't matter why) and I have button that add HTML code to the end of the text field (in a form). I know that there is the "select" command that selects a part in the text field (or all of it), is there an opposite command that find out what part is selected?

    Also, is there a command that can find where is the little stick that shows you where the new text you'll write will be? (in a text field, the user sees... Maybe it is also called a cursor? I dunno!)
     
    Rogare, Feb 20, 2008 IP
  2. greboguru

    greboguru Member

    Messages:
    78
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hi,

    The 'stick' is a 'caret' :)

    I don't know if these will be of any use (I've never had to do this) but try

    Javascript : Getting and Setting Caret Position in Textarea
    ===========================================
    http://blog.vishalon.net/Post/57.aspx

    and

    Cross Browser selectionStart/selectionEnd
    ===============================
    http://www.teria.com/~koseki/memo/xbselection/


    Hope this helps!
     
    greboguru, Feb 20, 2008 IP
  3. Rogare

    Rogare Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks! If there will be anything more, I'll post :)
     
    Rogare, Feb 21, 2008 IP