如何在javascript中获取ckeditor iframe对象

时间:2014-01-07 07:03:37

标签: javascript ckeditor

我想针对ckeditor iframe body编写onkeypress事件。如何获取ckeditor对象的对象,以便我可以针对ckeditor iframe body绑定onkeypress事件?

1 个答案:

答案 0 :(得分:4)

您可以在创建ckeditor实例以绑定onkeypress事件之前尝试使用以下代码:

CKEDITOR.on('instanceCreated', function(cke) {
cke.editor.on('contentDom', function() {
   if(cke.editor.name == "YourIntanceName") // YourIntanceName = name of teaxtarea
    {
        cke.editor.document.on('keypress', function(e) {
            var charCode = event.data.getKey();
        });
    }
});
});
相关问题