ajax在線聊天室(四)

聊天室的內容基本實現了,繼續完善

加入了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();
     }
	 
   }	

   

}


//--------------------------------處理快捷鍵結束---------

如此一個聊天室就能使用了
發佈了87 篇原創文章 · 獲贊 4 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章