I need to insert an image element into text in an iframe in design mode. That part I can do:
Expand|Select|Wrap|Line Numbers
- var sel = oEditor.eFrameDoc.selection;
- var range = sel.createRange();
- range.pasteHTML('<img src="'+imagePath+'" border="0" />');
In Gecko, I can insert a node dynamically, as one would expect, thus:
Expand|Select|Wrap|Line Numbers
- var sel = oEditor.eFrameWindow.getSelection();
- var range = sel.getRangeAt(0);
- var img = document.createElement('img');
- img.setAttribute('src', imagePath);
- img.setAttribute('border', 0);
- range.insertNode(img);
IE's TextRange is limited -- you can't insert DOM elements directly. So I guess what I need is a way to maybe split an IE TextArea either side of a new "empty element" (whatever that might be), then use emptyObject.insertBefore(img) -- but I'm only guessing.
I've Googled this to death over several hours to no avail (except to find this site! :) Any assistance would be greatly appreciated.
Gruvin.