Get selected text and rewrite it

  •  11-25-2005, 3:06 PM

    Get selected text and rewrite it

    I have the following Editor declaration:
          <ce:editor ID="Editor" Runat="server"
            AutoConfigure="Full"
            AutoParseClasses="true"
            BorderWidth="0"
            DisableAutoFormatting="false"
            EnableStripScriptTags="false"
            FilesPath="/sitecore/Shell/Editor"
            Focus="false"
            FrameStyle="margin:0"
            Height="100%"
            ShowDecreaseButton="false"
            ShowEnlargeButton="false"
            ThemeType="Office2003"
            Width="100%"
            UseRelativeLinks="true"
            UseSimpleAmpersand="true">
          </ce:editor>
    When I try to get a selected text via JScript code:

      var editor1 = document.getElementById('CE_Editor_ID'); 
      var editselection=editor1.GetSelection();  
      if(editselection.rangeCount > 0)
      {
                    var r=sel.getRangeAt(0);
                    var clonedSelection = r.cloneContents();
                    var div = document.createElement('div');
                    div.appendChild(clonedSelection);
                    r.collapse(true);
                    alert(div.innerHTML);
       }

     
    I can not get property editselection.rangeCount worked. It looks like this property does not exist. Where I was wrong?
    How can I get a selected HTML text and replace it with my own?
    I used the example from the forum but it seems does not work: http://www.cutesoft.net/forums/10645/ShowPost.aspx 
    As I can see from assembly I get 5.0 version. Thank you in advance.  
View Complete Thread