Customised image selector unable to work in Chrome v13.0.782.220 m

  •  09-14-2011, 6:36 AM

    Customised image selector unable to work in Chrome v13.0.782.220 m

    Hi,
     
    I have followed some postings I saw in the forum on how to do up a image selector using the CuteEditor. I have followed them and implemented it as a control. The codes are as below. The code works fine in ie9 and Firefox but is unable to work in Chrome. I did some checking and found that the following statement returns -1 --> editdoc.images. No matter how I tried, I could not get it to work. Any help is greatly appreciated.
     
    Cheers,
    huatz
     
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td valign="top">
            <div style="position:absolute;z-index:-100">
       <CE:Editor id="HtmlEditor" URLType="SiteRelative" UseRelativeLinks="true" runat="server" Width="1" Height="1" AutoConfigure="None" ShowHtmlMode="False" ShowPreviewMode="False" EnableContextMenu="false" ShowGroupMenuImage="False" ShowBottomBar="False" BackColor="White" BorderColor="White"></CE:Editor><div style="display:none"><asp:TextBox ID="uiSource" runat="server" Text="foo" /></div>
      </div>
      <asp:TextBox id="imageFld" runat="server" />
      <INPUT type="button" value="Select Image" class="<%=styleFile %>" onclick="<%=HtmlEditor.ClientID%>callInsertImage()" id="Insert Image" NAME="Insert Image">
          
     </td>
    </tr>
    </table>
    <script language="javascript">
        function <%=HtmlEditor.ClientID%>callInsertImage()
        {
         var editor1 = document.getElementById('<%=HtmlEditor.ClientID%>');
            editor1.FocusDocument();
            var editdoc = editor1.GetDocument();
            editor1.ExecCommand('new');
            editor1.ExecCommand('InsertImage');
            <%=HtmlEditor.ClientID%>InputImageURL();
        }
        function <%=HtmlEditor.ClientID%>InputImageURL()
        {
            var editor1 = document.getElementById('<%=HtmlEditor.ClientID%>');
            var editdoc = editor1.GetDocument();
            var imgs = editdoc.images;
            if(imgs.length>0)
            {
                var path1=imgs[imgs.length-1].src.split('cmsresource/');
                editor1.ExecCommand('new');
                document.getElementById('<%=imageFld.ClientID%>').value = path1[1];
                document.getElementById('<%=imageFld.ClientID%>').focus();
                document.getElementById('<%=uiSource.ClientID%>').value = path1[1];
               
                //editor1.getHTML();
                //editor1.ExecCommand('new');
            }
            else
            {
                setTimeout(<%=HtmlEditor.ClientID%>InputImageURL,5000);
            }
        }
    </script>
     

     

    Filed under:
View Complete Thread