Fog Creek Software
Discussion Board

Content Editable

The #1 entry in Joel's list is to make Gecko's (ie Firefox, Mozilla et al), method of enabling content to be editable compatible with IE.

For clarification the method in IE is

        doc.body.contentEditable = true;

And Gecko's

        doc.designMode = "on";

The code to differentiate between the two document models (which you have to do anyway), covers the switch between how to enable content editing.  At a syntax level there's no point in constraining designMode to just the body of the document.

The structural difference is that the Gecko flag applies to the whole document and you can set it immediately after opening the object.  In IE you need an existing body tag before being able to set it editable.

This makes it easier, not harder, in Gecko to create HTML editors.

Simon Lucy
Friday, June 18, 2004

You can read more here:

Friday, June 18, 2004

Sure mozilla has designMode, however it isn't set on an individual element so it's an all or nothing setting. With content editable you can just set certain areas of the page as editable rather than the whole thing (unless you want to of course). IE is far more flexible and it's implementation is more mature. Check out mozile for something begining to approach content editable.

Ben Meadowcroft
Friday, June 18, 2004

Correct me if I am wrong, but couldn't I, as an end user, still type something like:

javascript:alert(doc.body.contentEditable = false)

into the address bar, and override your setting to make the content editable?

That's the real issue I've always seen with browser-based anything. Any restrictions you put on the HTML document, I can undo.

Friday, June 18, 2004

In fact, for those of you feeling a little bored this morning type:

javascript:alert(doc.designMode = "on")

into your address bar. Fun with JoS!


Friday, June 18, 2004

doc.body.contentEditable is the entire visible document so far as the user is concerned, so the distinction, in this regard seems spurious.

Yes you can set doc.body.{some element}.contentEditable but I find that less controllable. 

HTML is a blunderbuss for this.

Simon Lucy
Friday, June 18, 2004

If I remember rightly to get content editable on multiple controls using Gecko you'd wrap them in their own iframe.

However, from some work I did (6 months or more now) in the past having multiple editable controls in IE was grindingly slow so it wasn't something I really got into.

Simon Lucy
Friday, June 18, 2004

*  Recent Topics

*  Fog Creek Home