日期:2014-05-16 浏览次数:20426 次
<!DOCTYPE html>
<html>
<head>
<title>测试ctrl+Enter</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<textarea name="ckeditorContent" id="ckeditorContent" cols="80" rows="30"></textarea>
<script type="text/javascript">
CKEDITOR.replace('ckeditorContent');
function keydown(e){
if(e.keyCode==13&&e.ctrlKey)
{
alert('按下了ctrl+Enter');
CKEDITOR.instances['ckeditorContent'].setData("");//加了这句后,再次按下ctrl+Enter,认不到了,怎么解决?
}
}
CKEDITOR.on('instanceReady', function (e) {
if(e.editor.document.$.addEventListener)
e.editor.document.$.addEventListener('keydown',keydown,false);
else if(e.editor.document.$.attachEvent)
e.editor.document.$.attachEvent('onkeyup',function(e){keydown(e)});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>测试ctrl+Enter</title>
<script type="text/javascript" src="ckeditor.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<textarea name="ckeditorContent" id="ckeditorContent" cols="80" rows="30"></textarea>
<script type="text/javascript">
CKEDITOR.replace('ckeditorContent');
function keydown(e){
if(e.keyCode==13&&e.ctrlKey)
{
alert('按下了ctrl+Enter');
CKEDITOR.instances['ckeditorContent'].setData("",function(){
if(this.document.$.addEventListener)
this.document.$.addEventListener('keydown',keydown,false);
&