tinymce-3 – TypeError:window.tinyMCE.execInstanceCommand不是函数

我无法在wordpress编辑器添加任何短代码.它显示 – 未捕获TypeError:对象[object Object]没有方法’execInstanceCommand’. plesase帮助我解决这个问题.

代码(tinymce.js)

function init() {
    tinyMCEPopup.resizetoInnerSize();
}

function getCheckedValue(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function tjshortcodesubmit() {

    var tagtext;

    var tj_shortcode = document.getElementById('tjshortcode_panel');

    // who is active ?
    if (tj_shortcode.className.indexOf('current') != -1) {
        var tj_shortcodeid = document.getElementById('tjshortcode_tag').value;
        switch(tj_shortcodeid)
{
case 0:
    tinyMCEPopup.close();
  break;

case "button":
    tagtext = "["+ tj_shortcodeid + "  url=\"#\" style=\"white\" size=\"small\"] Button text [/" + tj_shortcodeid + "]";
break;

case "alert":
    tagtext = "["+ tj_shortcodeid + " style=\"white\"] Alert text [/" + tj_shortcodeid + "]";
break;

case "toggle":
    tagtext = "["+ tj_shortcodeid + " title=\"Title goes here\"] Content here [/" + tj_shortcodeid + "]";
break;

case "tabs":
    tagtext="["+tj_shortcodeid + " tab1=\"Tab 1 Title\" tab2=\"Tab 2 Title\" tab3=\"Tab 3 Title\"] [tab]Insert tab 1 content here[/tab] [tab]Insert tab 2 content here[/tab] [tab]Insert tab 3 content here[/tab] [/" + tj_shortcodeid + "]";
break;

default:
tagtext="["+tj_shortcodeid + "] Insert you content here [/" + tj_shortcodeid + "]";
}
}

if(window.tinyMCE) {
        //Todo: For QTranslate we should use here 'qtrans_textarea_content' instead 'content'
            window.tinyMCE.execInstanceCommand('content','mceInsertContent',false,tagtext);
            //Peforms a clean up of the current editor HTML. 
            //tinyMCEPopup.editor.execCommand('mceCleanup');
            //Repaints the editor. Sometimes the browser has graphic glitches. 
            tinyMCEPopup.editor.execCommand('mceRepaint');
            tinyMCEPopup.close();
        }
        return;
    }
我有同样的问题.将您的代码更改为此,它应该工作:
if(window.tinyMCE) {

    /* get the TinyMCE version to account for API diffs */
    var tmce_ver=window.tinyMCE.majorVersion;

    if (tmce_ver>="4") {
        window.tinyMCE.execCommand('mceInsertContent',tagtext);
    } else {
        window.tinyMCE.execInstanceCommand('content',tagtext);
    }

    tinyMCEPopup.editor.execCommand('mceRepaint');
    tinyMCEPopup.close();
    }
    return;
}

注意:由于缓存了.js文件,因此您需要进行硬刷新才能使其正常工作.如果您仍然看到相同的控制台错误,那可能是原因.

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...