Cursor position after set_html(content); is called from Javascript

2 posts, 0 answers
  1. Brian Garson
    Brian Garson avatar
    54 posts
    Member since:
    Jan 2008

    Posted 07 Jun 2011 Link to this post


    I'm trying to sort out a way to avoid having the cursor at position 0 in the editor after using the editor.set_html("I added some text"); function from javascript.  It seems in  when set_html is used your cursor automatically moves to position 0. You can see from your example on your site by clicking set_html 

    Is there any workaround for this?  In short what I'm trying to accomplish is to Filter the contents of the editor and replace that content, via JavaScript.


  2. Rumen
    Rumen avatar
    14351 posts

    Posted 10 Jun 2011 Link to this post

    Hi Brian,

    You can set the cursor to the end of the content after using the set_html() method using the code below:

    <telerik:radeditor runat="server" ID="RadEditor1">
           Here is sample content!
    <input type="button" value="reset" onclick="ResetContent();return false;" />
    <script type="text/javascript">
        function ResetContent() {
            var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object
            editor.set_html("test"); //reset the content
            var doc = editor.get_document();
            doc.execCommand("SelectAll", null, false);

    All the best,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top