FCKeditor利用js插入图片以及统计当前输入字数方法

 

<%@ import namespace="System"%>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Diagnostics"%>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<script language="C#" runat="server">
    
protected void Page_Load(object sender, EventArgs e)
    { 
    } 

</script>
<form id="form1" runat="server">
<fckeditorv2:fckeditor id="FCKeditor" runat="server" Width="580px" EnableXHTML="true" EnableSourceXHTML="true" basepath="~/FCKeditor/" height="500px"></fckeditorv2:fckeditor> 

</form> 

<INPUT TYPE="button" onclick="InserImg()" value="插图片"> 已经输入了<span id="ShowTextLength">0</span>个字符了
<BR>
当前字符:
<INPUT TYPE="text" id="ddd" size=100> 

<script language="Javascript">
<!--     
function InserImg()
{
var oEditor 
= FCKeditorAPI.GetInstance('FCKeditor');
oEditor.InsertHtml(
"<img src=http://www.baidu.com/img/logo.gif>");
oEditor.EditorDocument.body.onkeyup();


function FCKeditor_OnComplete( editorInstance )
{
   
// editorInstance.Events.AttachEvent( 'OnStatusChange', DoSomething ) ;
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor');
    oEditor.EditorDocument.body.onkeyup
=function ()
    {
        $(
"ShowTextLength").innerHTML =oEditor.EditorDocument.body.innerHTML.length;
        $(
"ddd").value =oEditor.EditorDocument.body.innerHTML;
    } 



function $(id){
return document.getElementById(id)}
//-->
</script> 

 
url:http://blog.csdn.net/sejie10011/archive/2008/09/26/2984883.aspx

posted @ 2011-05-19 11:17  轩~雨~阁  阅读(922)  评论(0编辑  收藏  举报