当在 FCKeditor 2 textarea 中输入内容时,我需要触发自定义 javascript 函数。但是,我进行了广泛的搜索,但找不到答案。想以某种方式将 onkeypress="customfunction()" 添加到文本区域。
谢谢你的帮助!
当在 FCKeditor 2 textarea 中输入内容时,我需要触发自定义 javascript 函数。但是,我进行了广泛的搜索,但找不到答案。想以某种方式将 onkeypress="customfunction()" 添加到文本区域。
谢谢你的帮助!
最后通过一些提示找到了一些东西。下面是如何在 FCKeditor 2.0 上执行 onkeypress。您需要在调用编辑器代码后加载此 javascript:
function FCKeditor_OnComplete(editorInstance){
if (document.all) { // If Internet Explorer.
editorInstance.EditorDocument.attachEvent("onkeydown", function(event){alert('key was pressed');} ) ;
} else { // If Gecko.
editorInstance.EditorDocument.addEventListener( 'keypress', function(event){alert('key was pressed')}, true ) ;
}
}
这似乎有效:
CKEDITOR.instances.<yourEditorname>.document.on('key', function(event) { });