HTML DOM Document execCommand() 方法
實例
使選定的文本加粗:
document.execCommand("bold");
親自試一試
語法
document.execCommand(command, showUI, value)
參數
參數 |
描述 |
command |
要執行的命令的名稱:
- "backColor"
- "bold"
- "createLink"
- "copy"
- "cut"
- "defaultParagraphSeparator"
- "delete"
- "fontName"
- "fontSize"
- "foreColor"
- "formatBlock"
- "forwardDelete"
- "insertHorizontalRule"
- "insertHTML"
- "insertImage"
- "insertLineBreak"
- "insertOrderedList"
- "insertParagraph"
- "insertText"
- "insertUnorderedList"
- "justifyCenter"
- "justifyFull"
- "justifyLeft"
- "justifyRight"
- "outdent"
- "paste"
- "redo"
- "selectAll"
- "strikethrough"
- "styleWithCss"
- "subscript"
- "superscript"
- "undo"
- "unlink"
- "useCSS"
|
showUI |
布爾值。指定是否應顯示 UI。 |
value |
有些命令需要值才能完成。 |
返回值
類型 |
描述 |
布爾值 |
如果支持該命令,則為 true,否則為 false。 |