RichTextEditor Demo
Home Pricing

## editor.attachEvent()

Attaches an event handler that is executed.

#### Syntax

`editor.attachEvent(eventName,eventHandler)`

###### eventName

`Type: String`

`Specifies the name of the event to be called.`

###### eventHandler

`Type: function`

`A function to execute when the event is triggered.`

## Example:

1. <script>
2. editor1.attachEvent("exec_command_newdoc", function (state, cmd, value) {
3. state.returnValue = true;//handled, don't execute default action
4. this.setHTMLCode("<p>New Doc...</p>");
5. });
6. </script>

## editor.detachEvent()

Removes the specified event handler that was registered earlier with the attachEvent method.

#### Syntax

`editor.detachEvent(eventName,eventHandler)`

###### eventName

`Type: String`

`specifies the name of the event that is listened by the event handler.`

###### eventHandler

`Type: function`

`Reference to the event handler function to remove.`

## Related Links

attachEvent

detachEvent

Event change

Event selectionchange

Event exec_command