tinyMCE脚本的setContent()方法在Mozilla Firefox中不起作用

时间:2012-02-09 04:32:04

标签: javascript firefox tinymce

执行以下声明时出现问题:

tinyMCE.get('div_id_name').setContent(headerText);

此声明适用于除Mozilla Firefox之外的所有浏览器(我的是9.0)。

tinyMCE init code ..

嗨,Plz找到下面的代码,希望它会有所帮助。

tinyMCE.init({
    mode: "exact",
    elements: "mceBodyInput",
    theme : "advanced",
    editor_css: "/_scripts/tiny_mce/themes/ui_custom.css",
    theme_advanced_buttons1: buttons,
    theme_advanced_buttons2: "",
    theme_advanced_buttons3: "",
    theme_advanced_toolbar_location: "external",
    theme_advanced_default_background_color: "#eeeeee",
    theme_advanced_toolbar_align: "left",
    theme_advanced_resizing: true,
    theme_advanced_fonts: "Arial=Arial, Geneva;",

    plugins: "autoresize,paste,noneditable",

    setup: function(ed) {
        ed.onInit.add(function(ed) {
            var e = tinymce.DOM.get(ed.id + '_tbl');
            var ifr = tinymce.DOM.get(ed.id + '_ifr');
            e.style.height = (ifr.clientHeight - 2) + "px";
        });
        ed.onNodeChange.add(function(ed) {
            tinyMCE.moveToolbar(ed);
            var sl = document.getElementById("sectionLabel");
            if ($("editAreaDiv").style.visibility == "hidden") {
                sl.innerHTML = "";
            } else {
                switch (ed.id) {
                case "mceHeaderInput":
                    sl.innerHTML = "— Header";
                    break;
                case "mceBodyInput":
                    sl.innerHTML = "— Body";
                    break;
                case "mcePaymentInput":
                    sl.innerHTML = "— Payment Instructions";
                    break;
                case "mceSignatureInput":
                    sl.innerHTML = "— Signature";
                    break;
                case "mceFooterInput":
                    sl.innerHTML = "— Footer";
                    break;
                default:
                    sl.innerHTML = "";
                }
            }
        });

        ed.onActivate.add(function(ed) {
            ed.getBody().style.backgroundColor = "white";
        });
        ed.onDeactivate.add(function(ed) {
            ed.getBody().style.backgroundColor = "#eeeeee";
        });
    },

    onpageload: "hideEditor"
});

1 个答案:

答案 0 :(得分:0)

如果插入的内容为空,则Firefox存在问题。 您可以检查是否headerText.length > 0并根据此插入内容插入内容。如果你真的需要插入任何东西,你可以使用tinymce方式并将内容设置为“”;