Friday, April 22, 2005

Safari 1.3 designMode

In Safari 1.3, I try to turn iframe designMode="on".
I can type in something, copy/paste, and turn text bold by ctrl+b, but nothing happen when I try to use execCommand() to apply bold font.
Not sure what's going wrong, but I doubt either document or TextRange object not same as IE/Mozilla.

So far, the available resource is very limited. I see few people raise this question in Dave Hyatt blog, but no one have answer yet.
Event, Apple doesn't provide any sample.

Not sure is good idea to implement HTML editor for Safari 1.3.
Safari 1.3 is Apple a big step, but still have a lot of things need to improve.

1 comment:

Anonymous said...

Safari 3.0+ supports setting contentWindow.document.designMode. However Safari 1.3 - 2.0 only support contentDocument.designMode.

You can support both types of browsers by doing the following:
var edit_element = document.getElementById("edit");
edit_element.contentWindow.document.body.contentEditable = true;
if (edit_element.contentWindow.document.designMode) {
edit_element.contentWindow.document.designMode = "on";
} else if (edit_element.contentDocument.designMode) {
// Safari 1.3 - 2.0 only support setting contentDocument.designMode
edit_element.contentDocument.designMode = "on";
} else {
alert('your browser does not support design mode.');