fckeditor中键盘事件的问题

我使用fckeditor做在线编辑,用户输入Enter键则自动提交,并清空编辑器的内容。我捕捉了onkeydown或onkeyup事件,判断event.keyCode==13,则调用oEditor.Commands.GetCommand( "NewPage" ).Execute(),清空编辑器,运行时很奇怪,就第一次Enter键正确执行了onkeyup事件,接下来就再也没有触发onkeyup事件。。不知为什么?如果不执行“NewPage”的命令,每次enter键都能触发键盘事件,换用oEditor.SetHTML("")来清空,结果也一样,都只有第一个Enter键有用。。请各位帮忙看看什么原因?以下时代码


<script type="text/javascript" src="fckeditor/fckeditor.js"> </script>
<script type="text/javascript">
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.EditorDocument.attachEvent("onkeydown", editor_keydown);
editorInstance.EditorDocument.attachEvent("onkeyup", editor_keyup);
}
function editor_keydown()
{
var oEditor = FCKeditorAPI.GetInstance('inputmsg') ; 
    var keycode = oEditor.EditorWindow.event.keyCode;
    if(keycode==13)  {
 
    }
   
}
function clearInput()
{
var oEditor = FCKeditorAPI.GetInstance('inputmsg') ; 
oEditor.Commands.GetCommand( "NewPage" ).Execute(); //  oEditor.SetHTML("") ;
}

function editor_keyup()
{
var oEditor = FCKeditorAPI.GetInstance('inputmsg') ; 
    var keycode = oEditor.EditorWindow.event.keyCode;
 
    if(keycode==13)  {
    clearInput();
    }
}
</script>
<html>
<head>
</head>
<body>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('inputmsg') ;
oFCKeditor.BasePath = "fckeditor/" ;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.Height = 500 ;
oFCKeditor.Value = 'asdf' ;
oFCKeditor.Create() ;
</script>
</body>
</html>

加支付宝好友偷能量挖...


评论(0)网络
阅读(104)喜欢(1)JavaScript/Ajax开发技巧