Set cursor position in RadEditor

2 posts, 0 answers
  1. Michał
    Michał avatar
    1 posts
    Member since:
    May 2013

    Posted 22 May 2013 Link to this post

    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?
  2. Joana
    Admin
    Joana avatar
    205 posts

    Posted 27 May 2013 Link to this post

    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.
Back to Top