[Project_owners] Inserting text around selected text in Midas

Neil Deakin enndeakin at sympatico.ca
Fri Nov 12 10:50:18 EST 2004


David Murray wrote:

> Thanks for replying. I've tried both ways, but get plaintext each time.
>
> Here's the function:
>
> function ljcut() {
>     var mbox = document.getElementById("message").contentWindow;
>     var sel = mbox.getSelection();
>     sel = "<lj-cut>" + sel.toString() + "</lj-cut>";
>     getIFrameDocument("message").execCommand("insertHTML", false, sel);
> }

Er, toString ? You're asking the content to be converted into plain text 
here.

var range = sel.getRangeAt(0);
if (range) frag = range.cloneContents()

will return a document fragment which you can then just insert into the 
document using dom methods.

/ Neil



More information about the Project_owners mailing list