欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Fckeditor編輯器內(nèi)容長(zhǎng)度限制統(tǒng)計(jì)實(shí)現(xiàn)方法

 更新時(shí)間:2012年03月03日 00:15:12   作者:  
Fckeditor是一種大家常用的編輯器,但是他不能像網(wǎng)頁(yè)表單那樣利用document.getelementbyid能獲取得到值了,它必須通過(guò) FCKeditorAPI來(lái)操作,下面看看Fckeditor內(nèi)容長(zhǎng)度測(cè)試
先我們看最簡(jiǎn)單的就是編輯器的代碼了,簡(jiǎn)單得很同時(shí)大家也經(jīng)常看過(guò)。
復(fù)制代碼 代碼如下:

<script type="text/javascript" src="/editor/fckeditor.js"></script>
<script type="text/javascript">
<!--
var oFCKeditor = new FCKeditor( 'Content' ) ;
oFCKeditor.BasePath = "/editor/" ;
oFCKeditor.ToolbarSet = "User" ;
oFCKeditor.Value = '沒(méi)有最好,只有更好,大家努力' ;
oFCKeditor.Height = 450 ;
oFCKeditor.Width = 660 ;
oFCKeditor.Create() ;
//-->
</script>
<input type="button" value="檢測(cè)字?jǐn)?shù)(包括HTML代碼)" style="width:165px;" class="inputc" onClick="checklength()">
<script>

//檢測(cè)在線編器字符數(shù) ,他必須通過(guò)創(chuàng)建FCKeditorAPI來(lái)實(shí)現(xiàn),代碼如下。
復(fù)制代碼 代碼如下:

function checklength()
{
var Content;
var oEditor = FCKeditorAPI.GetInstance('Content') ;
Content=oEditor.GetXHTML(true)
alert("n當(dāng)前: "+Content.length+" 個(gè)字符");
return false;
}
</script>

再看實(shí)例,這里限制了fckeditor編輯器內(nèi)容的長(zhǎng)度哦,
復(fù)制代碼 代碼如下:

window.onload=function(){
function FCKeditor_OnComplete()
{
var editor = FCKeditorAPI.GetInstance('info') ;
editor.Events.AttachEvent('OnSelectionChange', editor_keydown);
}
function editor_keydown(editor)
{
var maxLength=3; //最大輸入字?jǐn)?shù)
content= $(editor.EditorDocument.body).text();
var len= content.length;
var $info =$('#info');//存放提示信息
if(len < maxLength){
.text("還可以輸入 "+(maxLength-len)+"字");
}
if(len == maxLength){
$info.text("字?jǐn)?shù)達(dá)到上限");
}
if(len > maxLength){
$info.text(" 輸入字符超過(guò)"+maxLength+"個(gè),請(qǐng)更改!");
}
}
FCKeditor_OnComplete()
}

相關(guān)文章

最新評(píng)論