Connecting Tech Pros Worldwide Forums | Help | Site Map

Get Caret Position (FireFox)

ryanmhuc@yahoo.com
Guest
 
Posts: n/a
#1: Nov 3 '05
Is there a way to get the caret position of a text input using FireFox.
I am aware of ways to such with IE but have been unable to accomplish
in FireFox and have not found a solution in the groups or web. Anyone?
Thanks


Martin Honnen
Guest
 
Posts: n/a
#2: Nov 3 '05

re: Get Caret Position (FireFox)




ryanmhuc@yahoo.com wrote:
[color=blue]
> Is there a way to get the caret position of a text input using FireFox.[/color]

For textControls in Firefox/Mozilla you can read out
textControl.selectionStart
textControl.selectionEnd
selectionEnd should be the caret position.
To change the selection you can use
textControl.setSelectionRange(newSelectionStart, newSelectionEnd)

Opera 8 also supports those properties/methods on text controls.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread