I'm using the bootbox.js prompt as the following :
document.getElementById('picture').addEventListener('click', function(){
bootbox.prompt('URL de l\'image: ', function(result){
document.execCommand('insertImage', false, result);
});
}, false);
But this line document.execCommand('insertImage', false, result);
seems that it doesn't work.
I tried to do an alert instead and it worked.
Why the document.execCommand()
doesn't executed ? and how can I solve this problem ?
Now, this is just more than I can fit in a comment.
The element that is set as contenteditable="true"
has likely lost its focus ( or it's contenteditable = true
is not set )
Try
document.getElementById('picture').addEventListener('click', function(){
var editabletarget = document.getElementById("currentcontenteditableid");
bootbox.prompt('URL de l\'image: ', function(result){
/* reset editable and focus() */
editabletarget.setAttribute("contentEditable", true);
editabletarget.focus();
document.execCommand('insertImage', false, result);
});
}, false);
Replacing currentcontenteditableid
with your current contenteditable element id.
Give that a try, hope works ( seems likely ). If not please give us
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.