Re: Problems with editor.GetSelection() in IE

  •  05-20-2008, 10:48 PM

    Re: Problems with editor.GetSelection() in IE

    <?php

    $editor=new CuteEditor();
    $editor->ID="Editor1";
    $editor->Text="Type here..";
    $editor->FilesPath="CuteEditor_Files";
    $editor->TemplateItemList="G_start,Bold,Italic,Underline,Separator,JustifyLeft,JustifyCenter,JustifyRight,G_end";
    $editor->CustomAddons = "<img title=\"Using oncommand\" class=\"CuteEditorButton\" onmouseover=\"CuteEditor_ButtonCommandOver(this)\" onmouseout=\"CuteEditor_ButtonCommandOut(this)\" onmousedown=\"CuteEditor_ButtonCommandDown(this)\" onmouseup=\"CuteEditor_ButtonCommandUp(this)\" ondragstart=\"CuteEditor_CancelEvent()\" Command=\"MyCmd\" src=\"CuteEditor_Files/Images/contact.gif\" />";
    $editor->Draw();

    $ClientID=$editor->ClientID();
    $editor=null;

    ?>

    <br />
    <input type="submit" value="Submit" ID="Submit1" NAME="Submit1" /><br />
    <script language="JavaScript" type="text/javascript" > 

    function CuteEditor_OnCommand(editor,command,ui,value)
    {
       // get the cute editor instance
       var editor1 = document.getElementById('CE_Editor1_ID');

       // get the active editor document
       var editdoc = editor1.GetDocument();

       //handle the command by yourself
       if(command=="MyCmd")
       {
          alert(getSelectedHTML());
          editor1.PasteHTML("Hello World"+ getSelectedHTML());
          return true;
       }

       function getSelectedHTML(){
          var rng=null,html="";
          if (document.selection && document.selection.createRange){
            rng=editdoc.selection.createRange();
            html=rng.htmlText||"";
          }else if (window.getSelection){
            rng=editwin.getSelection();
            if (rng.rangeCount > 0 && window.XMLSerializer){
              rng=rng.getRangeAt(0);
              html=new XMLSerializer().serializeToString(rng.cloneContents());
            }
          }
          return html;
        }
    }
    </script>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View Complete Thread