vendredi 20 février 2015

How to insert images with my own WYSIWYG editor

I'm building my own WYSIWYG editor, using an iframe, I'd like to find just a way to simply insert an image! I already got the Bold style, Italic style, H1 and H2, using JS:



function bold(){
editor.document.execCommand("bold", false, null)
}

function italic(){
editor.document.execCommand("italic", false, null)

}
function h1(){
editor.document.execCommand('formatBlock',false,'h1');
}

function h2(){
editor.document.execCommand('formatBlock',false,'h2');
}


That works very well but I'm struggling with "Insert image button" Since I'm really new with coding, I was trying this:



function image(){
var image = prompt ("Paste or type a link", "http://")
editor.document.execCommand("createImage", false, image)


But that doesn't work. Please, if anyone knows how to insert an image... help!


A LOT OF THANKS IN ADVANCE!


Aucun commentaire:

Enregistrer un commentaire