The editor.AttachEvent( ) method requires two parameters:
editor.AttachEvent("event", functionReference);
The event parameter is the "on" version of the event name, while the function reference is just like the kind you assign to an object event handler property. The combination of AttachEvent( ) and DetachEvent( ) allows scripts to enable and disable scripted functionality as desired.
Example:
<script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("TextChanged",function() { }); editor.AttachEvent("ExecCommand",function() { }); } </script>
Event | Description |
---|---|
Load |
This event is invoked immediately after the RichTextEditor is fully loaded.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("Load",function() { }); } </script> |
Dispose |
This event occurs immediately when a RichTextEditor is removed successfully.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("Dispose",function() { }); } </script> |
TextChanged |
This event is raised if the content of RichTextEditor is changed.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("TextChanged",function() { }); } </script> |
SelectionChanged |
This event is raised if the actual selection in the editor area changes.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("SelectionChanged",function() { }); } </script> |
TabModeChanged |
This event is raised when switching between edit, code, and preview mode.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("TabModeChanged",function() { }); } </script> |
UpdateUI |
This event is raised when the editor updates the user interface state.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("UpdateUI",function() { }); } </script> |
PasteFilter |
This event is raised before the data is pasted into RichTextEditor. It allows you intercept the paste function and filter the content being pasted.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("PasteFilter", function (editor, info) { var html = info.Arguments[0]; var cmd = info.Arguments[1]; //filter html here info.ReturnValue = html; }); } </script> |
InitEvent |
This event is raised after the iframe document of the editor is reset. You can use
it to initialize the iframe document or attach events to the DOM in iframe.
Example: <script type='text/javascript'> var globaleditor = null; function RichTextEditor_OnLoad(editor) { editor.AttachEvent("InitEvent", function (argeditor, argevent) { globaleditor = argeditor; var win = argeditor.GetWindow(); var doc = win.document; if (doc.addEventListener) { doc.addEventListener("mouseover", editor_document_onmouseover, false); doc.addEventListener("mouseout", editor_document_onmouseout, false); } else { doc.attachEvent("onmouseover", editor_document_onmouseover); doc.attachEvent("onmouseout", editor_document_onmouseout); } }); } function editor_document_onmouseover(e) { if (!e) e = globaleditor.GetWindow().event; var domnode = e.target || e.srcElement; var rtenode = globaleditor.GetNodeFromDom(domnode); if (rtenode) rtenode.SetRuntimeAttribute("style", "text-decoration:underline", "mybehavior"); } function editor_document_onmouseout(e) { if (!e) e = globaleditor.GetWindow().event; var domnode = e.target || e.srcElement; var rtenode = globaleditor.GetNodeFromDom(domnode); if (rtenode) rtenode.SetRuntimeAttribute("style", null, "mybehavior"); } </script> |
UninitEvent |
This event is raised before the iframe document of the editor is reset. You can use
it to dispose all registered DOM elements before InitEvent occurs.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("UninitEvent", function (argeditor, argevent) { globaleditor = argeditor; var win = argeditor.GetWindow(); var doc = win.document; if (doc.removeEventListener) { doc.removeEventListener("mouseover", editor_document_onmouseover, false); doc.removeEventListener("mouseout", editor_document_onmouseout, false); } else { doc.detachEvent("onmouseover", editor_document_onmouseover); doc.detachEvent("onmouseout", editor_document_onmouseout); } }); } function editor_document_onmouseover(e) { if (!e) e = globaleditor.GetWindow().event; var domnode = e.target || e.srcElement; var rtenode = globaleditor.GetNodeFromDom(domnode); if (rtenode) rtenode.SetRuntimeAttribute("style", "text-decoration:underline", "mybehavior"); } function editor_document_onmouseout(e) { if (!e) e = globaleditor.GetWindow().event; var domnode = e.target || e.srcElement; var rtenode = globaleditor.GetNodeFromDom(domnode); if (rtenode) rtenode.SetRuntimeAttribute("style", null, "mybehavior"); } </script> |
PreCut |
This event is raised when starting to copy content in the editor. If ReturnValue=false, the action is canceled.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("PreCut", function (editor, info) { //set info.ReturnValue to false to cancel cut //info.ReturnValue = false; }); } </script> |
PreCopy |
This event is raised when starting to cut content in the editor. If ReturnValue=false, the action is canceled.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("PreCopy", function (editor, info) { //set info.ReturnValue to false to cancel copy //info.ReturnValue = false; }); } </script> |
ExecCommand |
This event is raised when ExecCommand is executed.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("ExecCommand", function (editor, info) { var commandname = info.Arguments[0]; }); } </script> |
ExecUICommand |
This event is raised when ExecUICommand is executed.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("ExecUICommand", function (editor, info) { var commandname = info.Arguments[1]; }); } </script> |
FullScreenChanged |
This event is raised when switching to fullscreen mode.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("FullScreenChanged", function () { }); } </script> |
Focus |
This event is raised when the editor receives focus.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("Focus", function () { }); } </script> |
Blur |
This event is raised when the editor loses focus.
Example: <script type='text/javascript'> function RichTextEditor_OnLoad(editor) { editor.AttachEvent("Blur", function () { }); } </script> |
Send feedback about this topic to CuteSoft. © 2003 - 2018 CuteSoft Components Inc. All rights reserved.