Connecting Tech Pros Worldwide Help | Site Map

Get Caret Position (FireFox)

  #1  
Old November 3rd, 2005, 02:35 PM
ryanmhuc@yahoo.com
Guest
 
Posts: n/a
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

  #2  
Old November 3rd, 2005, 02:45 PM
Martin Honnen
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
iFrame in desingMode="on", cursor positioning Canabeez answers 1 September 5th, 2009 04:15 PM
bold the selected text in textarea for firefox realin answers 2 December 26th, 2007 07:16 AM
Reading surrounding UBB tags in textarea selection dennis.sprengers@gmail.com answers 2 February 28th, 2007 04:35 PM