目录

HTML DOM 文档 execCommand()

示例

将选定的文本设为粗体:

document.execCommand("bold");
亲自试一试 »

描述

不推荐使用 execCommand() 方法。不要使用它。

applet 属性在所有新浏览器中返回一个空的 HTMLCollection。

HTML5 不支持 <applet> 元素。


语法

document.execCommand( command, showUI, value)

参数

Parameter Description
command The name of the command to execute:

"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 A Boolean.
Specifies if the UI should be shown or not.
value Some commands need a value to be completed.

返回值

类型 描述
布尔值 true如果支持该命令,否则false