代码之家  ›  专栏  ›  技术社区  ›  David

在fckeditor中按下键时触发javascript函数

  •  0
  • David  · 技术社区  · 14 年前

    当在FCKeditor 2文本区域中键入某些内容时,我需要触发一个自定义javascript函数。但是,我已经到处找了,找不到答案。希望以某种方式对文本区域执行诸如add-onkeypress=“customfunction()”之类的操作。

    谢谢你的帮助!

    2 回复  |  直到 14 年前
        1
  •  1
  •   David    14 年前

    最后用一些暗示词找到了一些东西。下面是如何在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 ) ;
        }
    
    }
    
        2
  •  0
  •   Ivo Wetzel    14 年前

    这似乎有效:

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

    在此处找到: http://cksource.com/forums/viewtopic.php?t=18286

    推荐文章