Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 466
petko_stankoski Avatar asked Mar 30 '12 14:03

petko_stankoski


2 Answers

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);
like image 71
Reimius Avatar answered Oct 12 '22 01:10

Reimius


function insertYourContent(text){
        tinyMCE.execInstanceCommand("elm1","mceInsertContent",false,text);
}
like image 33
ashutosh Avatar answered Oct 12 '22 03:10

ashutosh