Re: Anyway to get the the selected text with Javascript

  •  09-15-2005, 3:39 PM

    Re: Anyway to get the the selected text with Javascript

    Here are the client side APIs:

    function getHTML()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        // Get the editor HTML
        document.getElementById("myTextArea").value = editor1.getHTML();
       }  
       
       function setHTML()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        // Set the editor
        editor1.setHTML(document.getElementById("myTextArea").value);
       }
       
       
       function PasteHTML(html)
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        editor1.PasteHTML(html);
       }
       
       function SetActiveTab(tab)
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        editor1.SetActiveTab(tab);
       }
       
       
       function setFocus()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        editor1.FocusDocument();
       }
       
       
       function ExecCommand()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        var CommandObj = document.getElementById('Commands');
        var cmd = CommandObj.options[CommandObj.selectedIndex].text;
        var val = CommandObj.options[CommandObj.selectedIndex].value;
        editor1.ExecCommand(cmd,false,val);
       }
       
       function CE_attachEvent()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument();
        // attach Event
        editdoc.attachEvent('onkeypress',HandleChange);
       } 
       
       
       function HandleChange()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        //Get the editor content 
        var editdoc=editor1.GetDocument();
        alert(editdoc.body.innerHTML);
       }  
        
       
       function CE_detachEvent()
       {
        // get the cute editor instance
        var editor1 = document.getElementById('CE_Editor1_ID');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument();
        // detach Event
        editdoc.detachEvent('onkeypress',HandleChange);
       }

    To answer your question, you can just use the editor1.PasteHTML(html) method.

     
     

    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