Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

HTML | DOM execCommand() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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


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. 



<!DOCTYPE html>
            HTML DOM execCommand() Method
        <!--script to make text bold-->
            document.designMode = "on";
            function execfunction(event) {
    <!--onmouseout event when the user moves the mouse
    pointer after selecting, this execfunction()
    will execute.-->
    <body onmouseout = "execfunction(event)">
            Welcome to GeekforGeeks
            Document execCommand() Method
            The execCommand() method executes a specified
            command on selected text or section.
            Select some text in this page, and move the mouse
            pointer away from it. It will make the text bold.


Before Select the content:


After Select the content:


After Moving Mouse pointer:


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

  • Chrome
  • Internet Explorer 9.0
  • Opera 29.0
  • Firefox 41.0
  • Apple Safari 20.0

My Personal Notes arrow_drop_up
Last Updated : 08 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials