As shown earlier, some commands work on the current selection in a document. In IE, however, you can also let scripting assist with the selection with the aid of the TexTRange object. For example, the following function locates every instance of a string passed as a parameter and turns its text color to red:
The process is iterative. After creating a text range for the entire document body, the function repeatedly looks for a match of the string. Whenever there is a match, the matched word is selected, and the execCommand( ) method invokes the ForeColor command, passing the value red as the color. To continue searching through the range, the range is collapsed after the previously found item, and the selection is removed (by selecting a range of zero length).
Command | IE | Moz | Opera | Description | Value parameter |
---|
2D-Position | · | | | Makes absolute-positioned element inherently draggable (IE 5.5 or later) | Boolean to enable (true) or disable (false) dragging |
AbsolutePosition | · | | | Sets style.position property to absolute (IE 5.5 or later) | Boolean to enable (TRue) or disable (false) setting |
BackColor | · | · | · | Sets background color of current selection | Color value (name or hex triplet) |
Bold | · | · | · | Makes the current selection bold weight | None |
ContentReadOnly | | · | · | Locks the document | Boolean to enable (TRue) or disable (false) setting |
Copy | · | · | | Copies the range to the Clipboard (Moz signed scripts) | None |
CreateBookmark | · | | | Wraps an <a name=> tag around the range or modifies an existing <a> tag | A string of the anchor name; tag is removed if value is omitted |
CreateLink | · | · | · | Wraps an <a href=...> tag around the current selection | A string of a complete or relative URL |
Cut | · | · | · | Copies the range/selection to the Clipboard, then deletes range/selection (Moz signed scripts) | None |
DecreaseFontSize | | · | · | Reduces selection one HTML font size | None |
Delete | · | · | · | Deletes the range/selection | None |
FontName | · | · | · | Sets the font family of current selection | A string of the font family name |
FontSize | · | · | · | Sets the HTML font size of current selection | A string of the font size (17) |
ForeColor | · | · | · | Sets the foreground (text) color of current selection | Color value (name or hex triplet) |
FormatBlock | · | · | · | Wraps a block tag around the current object | HTML tag (e.g., <p>) as string |
Heading | | · | | Wraps a heading tag around the current object | HTML tag (e.g., <h1>) as string |
HiliteColor | | · | | Sets the background color of the selection | Color value (name or hex triplet) |
IncreaseFontSize | | · | · | Raises selection one HTML font size | None |
Indent | · | · | | Indents current selection | None |
InsertButton | · | | | Inserts a <button> tag at current insertion point | A string for the element ID |
InsertFieldset | · | | | Inserts a <fieldset> tag at current insertion point | A string for the element ID |
InsertHorizontalRule | · | | · | Inserts <hr> at current insertion point | A string of the rule size (not working) |
InsertHTML | | · | · | Inserts HTML markup into selection | HTML markup as string |
InsertIFrame | · | | | Inserts an <iframe> tag at current insertion point | A string of a URL for the src property |
InsertImage | · | · | · | Inserts an <img> tag at current text selection (IE 5 or later) | A string of a URL for the src property |
InsertInputButton | · | | | Inserts an <input type="button"> tag at current insertion point | A string for the element ID |
InsertInputCheckbox | · | | | Inserts an <input type="checkbox"> tag at the current insertion point | A string for the element ID |
InsertInputFileUpload | · | | | Inserts an <input type="file"> tag at the current insertion point | A string for the element ID |
InsertInputHidden | · | | | Inserts an <input type="hidden"> tag at current insertion point | A string for the element ID |
InsertInputImage | · | | | Inserts an <input type="image"> tag at current insertion point | A string for the element ID |
InsertInputPassword | · | | | Inserts an <input type="password"> tag at current insertion point | A string for the element ID |
InsertInputRadio | · | | | Inserts an <input type="radio"> tag at current insertion point | A string for the element ID |
InsertInputReset | · | | | Inserts an <input type="reset"> tag at current insertion point | A string for the element ID |
InsertInputSubmit | · | | | Inserts an <input type="submit"> tag at current insertion point | A string for the element ID |
InsertInputText | · | | | Inserts an <input type="text"> tag at current insertion point | A string for the element ID |
InsertMarquee | · | | | Inserts a <marquee> tag at current insertion point | A string for the element ID |
InsertOrderedList | · | · | · | Inserts an <ol> tag at current insertion point | A string for the element ID |
InsertParagraph | · | | · | Inserts a <p> tag at current insertion point | A string for the element ID |
InsertSelectDropdown | · | | | Inserts a <select> tag whose type is select-one at current insertion point | A string for the element ID |
InsertSelectListbox | · | | | Inserts a <select> tag whose type is select-multiple at current insertion point | A string for the element ID |
InsertTextArea | · | | | Inserts a <textarea> tag at current insertion point | A string for the element ID |
InsertUnorderedList | · | · | · | Inserts a <ul> tag at current insertion point | A string for the element ID |
Italic | · | · | · | Wraps an <i> tag around the range | None |
JustifyCenter | · | · | · | Center justifies the current selection | None |
JustifyFull | | · | · | Full justifies the current selection | None |
JustifyLeft | · | · | · | Left justifies the current selection | None |
JustifyRight | · | · | · | Right justifies the current selection | None |
LiveResize | · | | | Dynamically refresh element resizing in edit mode (IE 5.5 or later) | Boolean to enable (true) or disable (false) setting |
MultipleSelection | · | | | Allow multiple element selections in edit mode (IE 5.5 or later) | Boolean to enable (true) or disable (false) setting |
Outdent | · | · | · | Outdents the current selection | None |
OverWrite | · | | | Sets the input-typing mode to overwrite or insert | Boolean (TRue if mode is overwrite) |
Paste | · | · | | Pastes contents of the Clipboard at current insertion point or over the current selection (Moz signed scripts) | None |
Print | · | | | Displays Print dialog box (IE 5.5 or later) | None |
Redo | | · | · | Undoes the previous undo command | None |
Refresh | · | | | Reloads the current document | None |
RemoveFormat | · | · | · | Removes formatting from current selection | None |
SaveAs | · | | | Saves the page as a local file (optional file dialog) | A string of a URL for the path |
SelectAll | · | · | | Selects entire text of the document | None |
Strikethrough | · | · | · | Formats selection as strikethrough text | None |
StyleWithCSS | | · | | Use CSS markup (default true) | Boolean to enable (true) or disable (false) setting |
Subscript | · | · | · | Formats selection as subscript text | None |
Superscript | · | · | · | Formats selection as superscript text | None |
UnBookmark | · | | | Removes anchor tags from the selection or text range | None |
Underline | · | · | · | Wraps a <u> tag around the range | None |
Undo | | · | · | Undo previous command | None |
Unlink | · | · | · | Removes a link from the selection or text range | None |
Unselect | · | | · | Clears a selection from the document | None |
UseCSS | | · | · | Use CSS markup (deprecated in Mozilla) | Boolean to enable (true) or disable (false) setting |