HTML DOM Document execCommand() メソッド

定義と用法

execCommand() メソッドは廃止されました。使用しないでください。

applet 属性はすべての新しいブラウザで空のものが返されます。 HTMLCollection

HTML5 は <applet> 要素をサポートしていません。

代替案:

Document designMode 属性

Element contentEditable 属性

選択されたテキストを太字にする:

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 です。