[Project_owners] Inserting text around selected text in Midas

David Murray lid2000 at tpg.com.au
Sat Nov 13 02:34:20 EST 2004


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);
}

I'm completely out of ideas.

David.


Neil Deakin wrote:
> David Murray wrote:
> 
>> Actually, no, I'm still screwed. How can I use getSelection or 
>> something but get any HTML values as well? getSelection just seems to 
>> return plaintext (ie. "blah <b>blah</b> blah" would just return "blah 
>> blah blah").
>>
>> David.
>> (again)
>>
> Sounds like you're using the wrong getSelection method. You should be 
> using window.getSelection and not document.getSelection.
> 
> Or, you're trying to print the result. window.getSelection() will return 
> an nsISelection but it will be automatically converted to a string if 
> you try output it directly.
> 
> / 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