在编辑器事件上运行 JavaScript
附加一个事件处理函数,在事件发生时执行。
语法
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.
用法示例
editor1.attachEvent("exec_command_newdoc", function (state, cmd, value) {
state.returnValue = true;//handled, don't execute default action
this.setHTMLCode("<p>New Doc...</p>");
});editor.detachEvent()
移除之前通过 attachEvent 方法注册的指定事件处理函数。
语法
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.