简体   繁体   中英

Add text in TinyMce on position of the cursor, onClick on icon

How to add text in tinyMce in the position of the cursor, when one of the icons will be clicked? The icon has id = sInput_netadvimage.

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);
function insertYourContent(text){
        tinyMCE.execInstanceCommand("elm1","mceInsertContent",false,text);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM