聊天室的内容基本实现了,继续完善
加入了FCK editor可以发表情和图片,并且可以快捷键发言
//--------------------------------处理快捷键---------
//fck的自动事件监听方法
function FCKeditor_OnComplete( editorInstance ) {
var o=editorInstance.EditorDocument;
if(o.attachEvent){
o.attachEvent("onkeypress",editor_keypress);
}else{
o.addEventListener("keypress",editor_keypress,false);
}
}
function editor_keypress(e) {
//判断用户是否允许使用快捷键
if($$("isenter").checked){
//var oEditor = FCKeditorAPI.GetInstance('sendMsg');
var keycode = e.keyCode//oEditor.EditorWindow.event.keyCode;
if(keycode == 13) {
//按下键以后,产生的多余的段落标记的问题 </p><p>
var acontent=getEditorHtmlContents('sendMsg',true);
// str.length-13 因为编辑器会自动的在输入的内容后面加上 </p><p> -13正好能去掉。
acontent=acontent.substr(0,acontent.length-13);
FCKeditorAPI.GetInstance('sendMsg').EditorDocument.body.innerHTML=acontent;
//当按下回车键后,发送信息
sendMsg();
}
}
}
//--------------------------------处理快捷键结束---------
如此一个聊天室就能使用了