开发者

trigger javascript function when a key is pressed in fckeditor

开发者 https://www.devze.com 2023-01-27 13:09 出处:网络
I need to trigger a custom javascript function when something is typed into FCKeditor 2 textarea. However开发者_运维知识库, I have searched far and wide and can\'t find an answer to this. Would like t

I need to trigger a custom javascript function when something is typed into FCKeditor 2 textarea. However开发者_运维知识库, I have searched far and wide and can't find an answer to this. Would like to do something like add onkeypress="customfunction()" to the textarea somehow.

Thanks for any help!


managed to find something in the end using some hints of words. Here is how to do an onkeypress even on FCKeditor 2.0. You need to load this javascript AFTER the editor code is called:

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 ) ;
    }

}


This seems to work:

CKEDITOR.instances.<yourEditorname>.document.on('key', function(event) { });

Found here: http://cksource.com/forums/viewtopic.php?t=18286

0

精彩评论

暂无评论...
验证码 换一张
取 消