Inserting text into Firefox rich text editor

I'm trying to build a light-weight rich text editor that works in Firefox. So far so good, as I have the usual bold, URL, image, etc., stuff working. Where I'm stuck is inserting text. For example, if you want to insert "forum tags" for quotes, which we don't put in as HTML, how is that done? In IE, you can do it like this...

var box = document.getElementById(ctrl).contentWindow;
box.document.designMode = "on";
function makeQuote(cmd)
var edittext = box.document.selection.createRange();
var original = edittext.htmlText;

So in this case, selecting text in the editor then triggering the event would yield something like:
[quote]this is a quote[/quote]

How is this done in Firefox?


  • Check out FCKEditor at

    It provides a full set of editing controls that work with both the IE and Mozilla/Firefox edit systems.

    Even if it's not suitable you could learn a thing or two from the source, it's LGPL'ed.


  • Check out, works for both IE and Firefox!!

  • I'm well aware of FreeTextBox, and it's too bulky. It also doesn't render stuff in non-CSS mode in Firefox even though the latest version says it shoud.

  • unrelated, but:

  • Hey Jeff,

    Did you ever get anywhere with this? I'm in the same boat right now with my website. All I want to do is has very light weight rich text editor for users add and information about products (bullets underlines) color

Comments have been disabled for this content.