Phương thức execCommand() của HTML DOM Document

Định nghĩa và cách sử dụng

execCommand() Phương thức đã được hủy bỏ. Hãy không sử dụng nó.

Thuộc tính applet trả về trống trong tất cả các trình duyệt mới. HTMLCollection.

HTML5 không hỗ trợ phần tử <applet>.

Lời khuyên thay thế:

Thuộc tính designMode của Document

Thuộc tính contentEditable của phần tử Element

Mô hình

Làm cho văn bản được chọn đậm:

document.execCommand("bold");

Thử ngay

Cú pháp

document.execCommand(command, showUI, value)

Tham số

Tham số Mô tả
command

Tên lệnh cần thực hiện:

  • "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 Giá trị boolean. Định nghĩa có nên hiển thị UI hay không.
value Một số lệnh cần giá trị để hoàn thành.

Giá trị trả về

Loại Mô tả
Giá trị boolean Nếu hỗ trợ lệnh này, sẽ là true, nếu không thì là false.