VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-execcommand-method/

⇱ HTML DOM execCommand() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM execCommand() Method

Last Updated : 11 Jul, 2025

The DOM execCommand() method in HTML DOM is used to execute a command specified by the user on the editable selected section. 

Syntax:

document.execCommand( command, showUI, value )

Parameters: This method accepts three parameters which are listed below:

  • command: This parameter hold the name of command which is execute on the selected section. There are many commands in HTML some of them are: backcolor, bold, copy, cut, delete etc.
  • showUI: It holds the Boolean value which indicating whether the UI shown or not.
  • value: This parameter holds the value of commands.

Note: This method has been DEPRECATED and is no longer recommended.

Return Value: It returns a Boolean value. If the command is supported then it returns True otherwise returns False. 

Example:

Output:

Before Select the content:

👁 Image
After Select the content:

👁 Image
After Moving Mouse pointer:

👁 Image

Supported Browsers: The browser supported by DOM execCommand() Method are listed below:

Comment
Article Tags: