Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Ipswich
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying the Caret Position

    I am having trouble displaying the actual position of the caret within a text area. When the user clicks within the text area I would like the message "You are at position : xx" to be displayed where xx is the position.

    I am storing the Caret using:

    function storeCaret(textE1) {
    if (textE1.getCaretPosition)
    textE1.caretPos = document.selection.createRange().duplicate();
    }

    But I don't know how to display it, I have been to the URL

    http://www.faqts.com/knowledge_base/...d/1052/fid/130

    But it didn't really help me as I wasn't sure what changes i need to make to ge tit to display the caret instead of insert at the caret. Can anyone point me in the right direction.

    Cheers Pete

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I've delved into it a bit, and it seems that the browser uses coordinates (pixel dimensions from the top-left) to place the text (and create textRanges), and not a true caretPosition number.

    I otherwords, if there is a way to do what you seek, it won't be with that link.

    -Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •