Re: Get selected text and rewrite it

  •  03-20-2009, 1:32 AM

    Re: Get selected text and rewrite it

    Hi Amrutas ,
     
    Try this code:
     

      function CE_LineOutSelectionHTML() {

                     var editor1 = document.getElementById('<%=Editor1.ClientID%>');
                     var editor1doc = editor1.GetDocument();
                     var selectedhtml;
                     if(editor1doc.selection.type=="Control" )
                     {
                        selectedhtml = editor1doc.selection.createRange().item(0).outerHTML;
                     }
                     else
                     {
                     selectedhtml = editor1doc.selection.createRange().htmlText;
                     }
                     var html = "**BEFORESELECTION**" + selectedhtml + "**AFTERSELECTION**";
                     editor1.PasteHTML(html);
                     return;
              }

     
    Regards,
     
    Ken
View Complete Thread