CKeditor编辑器聚焦以及引用

这段时间做个论坛,回复框用了CKeditor,后来要用到回复以及引用聚焦到回复框的时候,发现原先的那个TEXTBOX框给覆盖了,后来研究解决了问题,分享给大家参考一下:

 <asp:TextBox ID="fck" runat="server" TextMode="MultiLine" Height="150px"   Width="98%"  ></asp:TextBox>   
            <script type="text/javascript"> var editor = CKEDITOR.replace('<%= fck.ClientID %>', { skin: 'kama' });</script>
              

注意要给 CKEDITOR.replace('<%= fck.ClientID %>', { skin: 'kama' })赋值为editor到后面用JS调用就直接聚焦到这个

<input type="button" value="回复" class="tabBBS_info_controle_return Fn_createPopwindow"  onclick="replay();">
<input type="button" value="引用" class="tabBBS_info_controle_import" onclick="quote('content_<%#Eval("ID")%>');">

JS回复引用代码:

function replay(){
  
   editor.focus();
     
}

function quote(id){
   var quote_text=document.getElementById(id).innerText;
   
   editor.setData("<br/><br/><fieldset><legend>引用</legend>"+quote_text+"</fieldset>");
   editor.focus();

}

还有就是鼠标聚焦插入图片

function addmypic(this_path) 
{ 
     editor.insertHtml("<img src='"+this_path+"'/>");
}

网上很多ckeditor的什么聚焦很多都是错的,记录一下。

这样就能实现一般论坛的回复和引用了~和百度聚焦CKEDITOR结果不一样,给需要的人吧~~

原文地址:https://www.cnblogs.com/double2012/p/2729469.html