JavaScript function not working in IE10

2 posts, 0 answers
  1. Shweta
    Shweta avatar
    6 posts
    Member since:
    Apr 2014

    Posted 15 May 2014 Link to this post


    I am using below javascript function to add some text in RadEditor on click of a button.

    function TestFunction()
          var editor = $find("<%= EditorID.ClientID %>");

    I want the text to be added at the current position of cursor in editor.In chrome and mozilla it is working fine. but for IE it is adding the text at the start of editor.
    Does anyone know how to resolve this problem with IE?

  2. Nikolay
    Nikolay avatar
    93 posts

    Posted 19 May 2014 Link to this post


    You can handle RadEditor's selectionChange event and save current cursor position. Then restore it before pasting the content. Here is an example: 
    <telerik:RadEditor ID="RadEditor1" Runat="server" OnClientSelectionChange="OnClientSelectionChange">
            <p>line 1</p>
            <p>line 2</p>
            <p>line 3</p>
    <telerik:RadButton ID="RadButton" runat="server" Text="paste content" OnClientClicking="OnClientClicking"></telerik:RadButton>
        var range;
        function OnClientSelectionChange(editor, args) {
            range = editor.getSelection().getRange(true);
        function OnClientClicking(button, args) {
            var editor = $find("<%=RadEditor1.ClientID%>");
            if (range) {
            editor.pasteHtml("<strong>new content</strong>");

    You can see how it behaves in this screencast.

    If this does not help, please provide a sample page with the scenario.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top