Problem writing custom functions

Last post 04-07-2004, 1:58 PM by Adam. 3 replies.
Sort Posts: Previous Next
  •  03-30-2004, 11:03 PM 616

    Problem writing custom functions

    I am trying to write a custom function that replaces text in the document. The following code is supposed to replace highlighted text with the string 'xxx' but instead just inserts 'xxx' into the document. In other words, it is supposed to replace the selected text -- but instead just inserts before it.

     

    Help! The pasteHtml method is doing an insert, rather than a replace.

     

    Thank you,

    Ken Williams

     

    ------

     

    <!-- #include virtual = "/CuteEditor/include_CuteEditor.asp" -->
    <html><body>
    <script language="JavaScript" type="text/javascript" >

    function Paste_Html(editorID,value)
    {
        EditorID = editorID+"_editBox";   
        var editor    = document.getElementById(EditorID);
        editor.focus();
     //editor.document.selection.clear();
        var sel = editor.document.selection.createRange();
        // don't try to insert HTML into a control selection (ie. image or table)
        if (editor.document.selection.type == 'Control') {
            return;
        }
        sel.pasteHTML(value);
    }
    </script>

     

    <%
     Dim editor
     Set editor = New CuteEditor
     
     
     editor.ID = "Editor1"
     editor.Text = "..."    //feed the editor with data
     editor.FilesPath = "/CuteEditor/CuteEditor_Files"
     editor.ImageGalleryPath = "/Uploads"
     editor.MaxImageSize = 50
     editor.CustomAddons = "<span title=""Custom Addons"" class=""button"" onclick=""javascript:Paste_Html('Editor1','xxx');"" type=""btn"" border=""0""> Custom button </span>"
     editor.Draw()
     %>

     

    </body></html>

  •  04-05-2004, 5:44 PM 632 in reply to 616

    Re: Problem writing custom functions

    Ken,

     

    This is another sample code for ASP version that shows customized buttons. Please check your mail box. I sent the whole source code to you today.

     

    <script language="JavaScript" type="text/javascript" >

    function Paste_Html1(editorID,value)

    {

         EditorID = editorID+"_editBox";

         var editor = document.getElementById(EditorID);

         editor.focus();

          var sel = editor.document.selection.createRange();

          // don't try to insert HTML into a control selection (ie. image or table)

          if (editor.document.selection.type == 'Control') {

             return;

    }

    sel.pasteHTML(value);

    }

    </script>

     

    <%

     

    'CustomAddons

     

    editor.CustomAddons = "<span title=""Custom Addons"" class=""button"" onclick=""var d = new Date(); Paste_Html1

    ('Editor1',d.toLocaleTimeString())"" type=""btn"" border=""0""> Custom button </span>"

     

    %>

     

    Let me know if you have questions.

     

     


    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

  •  04-05-2004, 8:47 PM 633 in reply to 632

    Re: Problem writing custom functions

    On my computer, your example exhibits the same problem as the code I wrote. The custom button inserts the text, even when a long string of text is selected.

     

    Thank you,

    -Ken W

     

  •  04-07-2004, 1:58 PM 643 in reply to 633

    Re: Problem writing custom functions

     Ken ,

     

    You need to call editor cut function to remove the highlighted text  first.

     

    <script language="JavaScript" type="text/javascript" >

    function  CutandInsertHTML(editorID,value)

    {

         EditorID = editorID+"_editBox";

         var editor = document.getElementById(EditorID);

     

          // call editor cut function to remove the highlighted text  first

         _Format(editorID,'Cut');

     

         editor.focus();

          var sel = editor.document.selection.createRange();

          // don't try to insert HTML into a control selection (ie. image or table)

          if (editor.document.selection.type == 'Control') {

             return;

    }

    sel.pasteHTML(value);

    }

    </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 as RSS news feed in XML