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

  •  01-21-2016, 3:11 AM

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

     Dear Kenneth,

     

    Here are the codes:

    1. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>    
    2.         
    3.     <html>    
    4.         <head>    
    5.             <title></title>    
    6.                 
    7.     <style type='text/css'>    
    8.     body     
    9.     {    
    10.         margin: 0px;     
    11.         padding: 0px;    
    12.     }    
    13.     </style>             
    14.        
    15.             <script language="javascript">  
    16.                 function callInsertFile() {  
    17.                     var editor = document.getElementById('<%=editor.ClientID%>');  
    18.                     editor.FocusDocument();  
    19.                     setTimeout(function() { delay_editor_function(editor) }, 500);  
    20.                     return false;  
    21.                 }  
    22.   
    23.                 function delay_editor_function(editor) {  
    24.                     editor.ExecCommand('new');  
    25.   
    26.                     InputURL();  
    27.   
    28.                     editor.ExecCommand('InsertDocument');  
    29.                 }  
    30.   
    31.                 function InputURL() {  
    32.                     var editor = document.getElementById('<%=editor.ClientID%>');  
    33.                     var editdoc = editor.GetDocument();  
    34.                     var links = editdoc.getElementsByTagName("a");  
    35.   
    36.                     var link_data = "";  
    37.                     for (var i = links.length - 1; i >= 0; i--) {  
    38.                         if (links[i].href != "") {  
    39.                             link_data = links[i].href;  
    40.                             break;  
    41.                         }  
    42.                     }  
    43.   
    44.                     if (link_data != "") {  
    45.                         document.getElementById('select_path').value = link_data;  
    46.                     }  
    47.                     else {  
    48.                         setTimeout(InputURL, 500);  
    49.                     }  
    50.                 }           
    51.             </script>     
    52.         
    53.         </head>    
    54.         <body>        
    55.             <form id="Form1" runat="server">    
    56.                 <table border="0" cellpadding="0" cellspacing="0">    
    57.                     <tr>    
    58.                         <td>  
    59.                             <CE:Editor id="editor" runat="server" Width="1" Height="1" BackColor="White" BorderColor="White"></CE:Editor>    
    60.                               
    61.                             <input type="button" value="Browse" onclick="return callInsertFile();" id="file_path_btn" style="width:150px;height:30px;"/>  
    62.                             <br />        
    63.                             <input type="text" id="select_path" value="" style="width:500px;" />  
    64.                         </td>    
    65.                     </tr>    
    66.                 </table>    
    67.             </form>    
    68.         </body>    
    69.     </html>    
     

    P.S.

    chrom return error:

    Uncaught HierarchyRequestError: Failed to execute 'insertNode' on 'Range': The node to be inserted is a 'A' node, which may not be inserted here. 

     

    IE return error:

    Object doesn't support property or method 'addEventListener' 

     

     

View Complete Thread