当点击其中一个图标时,如何在光标位置的tinyMce中添加文本?该图标的id = sInput_netadvimage。
答案 0 :(得分:17)
function insertYourContent(){
tinyMCE.activeEditor.execCommand('mceInsertContent', false, "Whatever text");
}
var myIcon = document.getElementById("sInput_netadvimage");
if(myIcon.attachEvent)
myIcon.attachEvent("onclick", insertYourContent);
else if(myIcon.addEventListener)
myIcon.addEventListener("click", insertYourContent, false);
答案 1 :(得分:2)
function insertYourContent(text){
tinyMCE.execInstanceCommand("elm1","mceInsertContent",false,text);
}