Click to See Complete Forum and Search --> : execcommand(insertimage) - additional attributes?


bryden
September 15th, 2004, 04:01 AM
Well, I have the same problem. I'm working on a WYSIWYG web editor and I want to add upload image option. It should upload chosen image to the webserver, resize it and make thumbnail.
When this is done, it should insert thumbnail into editor and make link to big image.

I insert with:
execCommand('InsertImage', false, imagePath)


But I am unable to find the way to create link to that image. In IE it wors fine, because IE automaticaly selects inserted image. Firefox, however, inserts the image but does not select it.



So does anybody have solution how to select inserted image - that is - how to add id="xyx" to inserted image?!

lcaos
August 2nd, 2010, 06:23 AM
In Firefox you've got to select the range manually

Assign oWysiwyg to your wysiwyg and

oSel=oWysiwyg.getSelection();
var range = oSel.getRangeAt(0);
var oElement = range.startContainer.childNodes[range.startOffset-1];
oSel=oWysiwyg.getSelection();
range = oWysiwyg.document.createRange();
range.selectNodeContents(oElement);
oSel.removeAllRanges();
oSel.addRange(range);

PeejAvery
August 2nd, 2010, 08:49 AM
Welcome to the forums lcaos. :wave: Please remember to keep your posts relevant. This thread is 6 years old!!!