O'Reilly logo

Dynamic HTML: The Definitive Reference, 3rd Edition by Danny Goodman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D. Editable Content Commands

Internet Explorer was the first browser to include a set of commands outside of the JScript context that worked directly with the document and (Win32 only) TextRange objects. In many cases, these commands mimic the functionality available through setting properties or invoking methods of the objects. Some of the newer commands operate within the context of the MSHTML Edit Mode. All of these commands exist outside of the primary document object model and are therefore treated separately in this appendix.

This mechanism comes in very handy when implementing a user-editable region (usually inside an iframe element) in a web page. The main page in such an environment typically contains scripts and toolbars to assist users in creating or modifying HTML content without users having to know anything about HTML. The commands connected to the tools perform actions, such as inserting images and styling text content. This same concept, including the very same command system, has been adopted by Mozilla and Opera to allow those browsers to support the design of a user interface (e.g., toolbars) for user-editable content.

The Command System

Access to these commands is through a set of document and (in IE only) TextRange object methods that are described in Chapter 2. These commands and syntax are:

execCommand("commandName"[, UIFlag[, value]])
queryCommandEnabled("commandName")
queryCommandIndeterm("commandName")
queryCommandState("commandName") queryCommandSupported(" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required