This is a migrated thread and some comments may be shown as answers.

Set cursor position in RadEditor

1 Answer 255 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michał
Top achievements
Rank 1
Michał asked on 22 May 2013, 01:40 PM
Hi,

I'm trying to set the cursor to the given position (let's say X).I've tried to do this in many ways but still not found the solution... 

We need to change the content of RadEditor but cursor position should be the same. There's no problem in IE9, but in FF/Chrome/Opera the caret is moving back to the beginning of the document. Do you have any ideas?

1 Answer, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 27 May 2013, 11:45 AM
Hello,

RadEditorSelection's client-side API offers getRange() and selectRange() methods to get / restore cursor position. You can review this article. RadEditor utilizes W3C Range and Microsoft TextRange objects and in a more complicated scenario you should use the standard objects. The following articles give more detailed information for the TextRange objects:

http://www.wrox.com/WileyCDA/Section/JavaScript-DOM-Ranges-Page-2.id-292302.html
http://www.quirksmode.org/dom/range_intro.html
http://www.quirksmode.org/js/findpos.html

After creating a text range you will be able to use the following methods: move(), moveStart(), moveEnd() and select().

Regards,
Joana
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Michał
Top achievements
Rank 1
Answers by
Joana
Telerik team
Share this question
or