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>
<%@ 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
作者:轩雨阁
出处:http://www.cnblogs.com/xuanyuge/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接
如有问题,可以通过 wjoin@qq.com 联系我,非常感谢。