View Full Version : Displaying the Caret Position

08-29-2002, 10:38 AM
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


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

08-29-2002, 12:04 PM
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 :D