Cute Editor Method not work in all browsers

Last post 10-18-2011, 7:19 AM by ketty00. 2 replies.
Sort Posts: Previous Next
  •  10-05-2011, 6:39 AM 70288

    Cute Editor Method not work in all browsers

    Getting the Active Editor Selection


    In order to find the active editor selection, you would type:

    // get the active editor selection

    var sel = editor1.GetSelection();
     
    This method is retrieve empty string in all browsers except IE.. Why!!
    I need this method to work in all browsers not just IE. 
  •  10-06-2011, 7:43 AM 70297 in reply to 70288

    Re: Cute Editor Method not work in all browsers

    Hi mrelkapany1986,
     
    Please try the example below.
     
    <?php require_once "cuteeditor_files/include_CuteEditor.php" ?>  
    <html>    
    <body>    
            <form id="form1" method="POST">    
                <?php    
                    $editor=new CuteEditor();    
                    $editor->Text="Type here";    
                    $editor->ID="Editor1";   
                    $editor->Draw();    
                ?>  
       
                <input type="button" value="show editor selection" onclick="GetContent()" />
            </form>    
    </body>    
    </html>
    <script>
    function GetContent()
    {
        alert(getSelectedHTML());
    }
    function getSelectedHTML()      
    {         
        
          var editor1 = document.getElementById('CE_Editor1_ID');
          var rng=null,html="";            
             
          // get the active editor document   
          var editdoc = editor1.GetDocument();   
     
          // get the active editor window    
          var editwin = editor1.GetWindow();      
          if (document.selection && document.selection.createRange)      
          {         
                rng=editdoc.selection.createRange();      
               if( rng.htmlText )       
               {       
                  html=rng.htmlText;       
               }       
               else if(rng.length >= 1)       
               {       
                  html=rng.item(0).outerHTML;       
               }      
          }      
          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>
     
     
    Regards,
     
    Ken
  •  10-18-2011, 7:19 AM 70437 in reply to 70297

    Re: Cute Editor Method not work in all browsers

    I really need it.
View as RSS news feed in XML