Re: How to manually set IMG src in custom dialog

  •  11-15-2010, 1:49 PM

    Re: How to manually set IMG src in custom dialog

    Dear Tobster,
     
    Please refer to the following code:
    <%@ Page Language="C#"%>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
        <head>
       <script language="JavaScript" type="text/javascript" >
           function changeImg() {
               var editor1 = document.getElementById('<%=Editor1.ClientID%>');          
               //Get the editor content
               var editdoc = editor1.GetDocument(); 
               var range = editdoc.selection.createRange();
               if (editdoc.selection.type == 'Control') {
                   if (range.length == 1) {
                       var element = range.item(0);
                       if (element.tagName == 'IMG') {
                           //please add your code here
                           alert(element.src);
                       }
                   }
               }
           }
      </script>  
     <body>
            <form id="Form1" runat="server">
       <table cellpadding="15">
        <tr>
         <td>
          <CE:Editor id="Editor1"  runat="server"></CE:Editor><br />
          &nbsp;<br/><br/>         
          <p style="width:600">   
          <INPUT type=button value="change image" onclick="changeImg()" ID="Button1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </P>
          <br>   
          &nbsp;
        </td>
        </tr>
       </table> 
      </form>
     </body>
    </html>
    Thank you for asking
    Eric@cutesoft.net
View Complete Thread