...

View Full Version : Displaying the Caret Position



pthompson2002
08-29-2002, 09: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

www.faqts.com/knowledge_base/view.phtml/aid/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

beetle
08-29-2002, 11:04 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum