[Project_owners] Inserting text around selected text in Midas

David Murray lid2000 at tpg.com.au
Sun Nov 14 00:40:56 EST 2004


I honestly can't figure this one out. It's been getting the better of me 
for nearly 6 months now. If anyone can paste something or refer me to 
similar code that works, it'd be great. Apologies for being so useless.

David.

Neil Deakin wrote:
> 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
> 
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 
> 
> 
> 



More information about the Project_owners mailing list