本文介绍了HTML编辑器在FF和chrome中无法正常运行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Ajax控件HTML编辑器来获取和显示数据.我正在使用charecter计数器,并且也在客户端进行验证.它在IE中可以正常工作,但在FF和chrome中则不能.在FF和chrome中,它不计数并且不更改验证颜色(错误),但是在IE中,它可以(正确).谁能帮我???代码如下:

Hi every body,

I am using Ajax control Html editor for geting and showing data. I am using charecter counters and also validate on client-side. It works fine in IE but not in FF and chrome. In FF and chrome it don''t count and don''t change validate color (wrong), but in IE it do (correct). Can any one help me??? Code is given below;

<custom:HtmlEditor ID="txtJobDetails"  runat="server" Height="150px" TabIndex="4" />
                            <asp:HiddenField ID="hfOldContants" runat="server" />
 <asp:Label ID="lblJobDetails" runat="server" Text="3000"></asp:Label>


并使用javascript;


and in javascript;

Sys.Application.add_load(function () {
            var editor = $find("<%= txtJobDetails.ClientID %>");  // Editor's ID="myEditor" 

            var editPanel = editor.get_editPanel();
            var designPanel = editPanel.get_modePanels()[AjaxControlToolkit.HTMLEditor.ActiveModeType.Design];

            editPanel._setActive_saved = editPanel._setActive;

            editPanel._setActive = function () {
                if (this.get_activeMode() == AjaxControlToolkit.HTMLEditor.ActiveModeType.Design) {
                    var designPanel = this.get_activePanel();
                    designPanel.onContentChanged();
                }
                this._setActive_saved();
            };



            designPanel.onContentChanged = function () {
                var innerText;
                var hfOldContants = document.getElementById("<%=hfOldContants.ClientID %>");
                if (AjaxControlToolkit.HTMLEditor.isIE) {
                    innerText = this._doc.body.innerText;
                } else {
                    var div1 = document.createElement("div");
                    var html = new AjaxControlToolkit.HTMLEditor.jsDocument(true);
                    AjaxControlToolkit.HTMLEditor.__MozillaGetInnerText(div1, html);
                    innerText = html.toString();
                    delete div1;
                    delete html;
                }

                // HTML text length 
                var htmlTextLength = AjaxControlToolkit.HTMLEditor.Trim(this._doc.body.innerHTML).length;
                var txt = innerText;
                // Plain text length 
                var plainTextLength = innerText.replace(/^[\s]+/g, "").replace(/[\s]+$/g, "").replace(/[\s]+/g, " ").length;

                // Place here your code: 

                if (txt.length > 3000) {
                    $find("<%= txtJobDetails.ClientID %>").set_content(hfOldContants.value);
//                    $(this._doc.body).css('backgroundColor', '#FFFFD4');
                    alert("Exceeded Character Limit");
                    return false;
                }
                else {
                    document.getElementById("totalHtml").value = htmlTextLength + " Chars Used";
                    $("#<%=lblJobDetails.ClientID %>").html(3000 - (txt.length) + " chars left");

                    hfOldContants.value = AjaxControlToolkit.HTMLEditor.Trim(this._doc.body.innerHTML);
                    hfOldContants.innerHTML = AjaxControlToolkit.HTMLEditor.Trim(this._doc.body.innerHTML);

                    if ($("#<%=lblJobDetails.ClientID %>").html() == "3000 chars left") {
                        $(this._doc.body).css('backgroundColor', '');
                        $(this._doc.body).css('backgroundColor', '#FFFFD4');
                    }
                    else {
                        $(this._doc.body).css('backgroundColor', '');
                    }

                }
            }
});


问候,
Atiq


Regards,
Atiq

推荐答案




这篇关于HTML编辑器在FF和chrome中无法正常运行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:06