Re: Javascript Error when call "editor.ExecCommand('InsertDocument');"

  •  01-21-2016, 7:45 AM

    Re: Javascript Error when call "editor.ExecCommand('InsertDocument');"

    Hi,

     

    Please try the example page below, does it work for you?

     

    1. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    2. <%@ Page Language="C#"%>  
    3. <html>  
    4. <head>  
    5.     <title>ASP.NET WYSIWYG Editor - Use CuteEditor as a document selector</title>  
    6.     <style>  
    7.         body {   
    8.         text-align: center;   
    9.         margin-top:20px  
    10.         }  
    11.         .demo {   
    12.         text-align: left;   
    13.         width: 700px;  
    14.         border:solid 5px #CBCAC6;  
    15.         background-color:#fbfbfb;  
    16.         padding: 30px 30px 50px 30px;   
    17.         font-family:Segoe UI, Arial,Verdana,Helvetica,sans-serif;  
    18.         font-size: 100%;  
    19.         margin: 0 auto;   
    20.         }   
    21.     </style>  
    22. </head>  
    23. <body>  
    24.     <form id="Form1" runat="server">  
    25.         <div class="demo">  
    26.             <h3>  
    27.                 Use CuteEditor as a document selector</h3>  
    28.             <p>  
    29.                 This example demonstrates how to use CuteEditor as a document selector.  
    30.             </p>  
    31.             <br />  
    32.             <asp:TextBox ID="docFld" Width="300" runat="server" />  
    33.             <input type="button" value="Pick a file" onclick="callInsertImage()" id="Change"  
    34.                 runat="server" name="Change">  
    35.             <CE:Editor id="Editor1" runat="server" Width="1" Height="1" AutoConfigure="None"  
    36.                 ShowHtmlMode="False" ShowPreviewMode="False" EnableContextMenu="false" ShowGroupMenuImage="False"  
    37.                 ShowBottomBar="False" BackColor="White" BorderColor="White">  
    38.             </CE:Editor>  
    39.         </div>  
    40.     </form>  
    41.   
    42.     <script language="javascript">   
    43.       
    44.      function callInsertImage()    
    45.     {    
    46.             var editor1 = document.getElementById('<%=Editor1.ClientID%>');  
    47.             var editdoc = editor1.GetDocument();    
    48.             editdoc.body.innerHTML="";  
    49.             editor1.ExecCommand('insertdocument');  
    50.             InputURL();  
    51.             document.getElementById("<%=docFld.ClientID%>").focus();   
    52.     }     
    53.       
    54.     function InputURL()  
    55.     {   
    56.         var editor1 = document.getElementById('<%=Editor1.ClientID%>');  
    57.         var editdoc = editor1.GetDocument();    
    58.         var links = editdoc.getElementsByTagName("a");         
    59.         if(links.length>0&&links[links.length-1].href!="")    
    60.         {   document.getElementById("<%=docFld.ClientID%>").value = links[links.length-1].href;         
    61.         }    
    62.         else  
    63.         {  
    64.             setTimeout(InputURL,500);   
    65.         }     
    66.     }        
    67.     </script>  
    68.   
    69. </body>  
    70. </html>  
     

    Regards,

     

    Ken 

View Complete Thread