Re: Get selected text and rewrite it

  •  03-19-2009, 12:32 AM

    Re: Get selected text and rewrite it

    Hi,
     
    sir the PasteHTML method is not working properly for IE(6,7) in my case. I am selects a image and want to replace it with
                      varHtml = ("beforeimage" + image + "afterimage"),
     
    so im using the PasteHTML method. But it dont replace the image with varHtml, it appends the varHtml next to the image, so it becomes
                     image + ("beforeimage" + image + "afterimage")
     
    here image is my image tag <img height="200" alt="" src="http://cutesoft.net/LabTrackPNV4/NotebookImages/Demo.7.1/Winter.jpg" width="200" border="1" />
     
    This is working properly for FF and Safari, but not on IE(6,7).
     
    Here is the javascipt code for it
     
               function CE_LineOutSelectionHTML() {
                     var editor1 = document.getElementById('<%=Editor1.ClientID%>');
                     var editor1doc = editor1.GetDocument();
                
                     var selectedhtml = editor1doc.selection.createRange().htmlText;
                     var html = "**BEFORESELECTION**" + selectedhtml + "**AFTERSELECTION**";
                     editor1.PasteHTML(html);
                     return;
              }
     
     
    Please look into this guide us.
     
    Thanks in advance.
    Filed under:
View Complete Thread