最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

FCKEidtor 自動統(tǒng)計輸入字符個數(shù)(IE)

 更新時間:2009年05月29日 20:43:16   作者:  
由于項目需要,需要做字數(shù)統(tǒng)計,于是寫了一個JS計算字符個數(shù),如果輸入的字符數(shù)大于100個字符,就彈出提示,點擊【確定】后,自動截取為100個字符。
此方法支持IE 不支持火狐??赡苁且驗镕CKEidtor的keyup方法在火狐下不被支持。
FCKEditor編輯器換為TextBox,應(yīng)該就沒有問題了。
前臺:
復(fù)制代碼 代碼如下:

<tr>
<th>
短敘述
<br />
(限100中文字)<br />
當前文字個數(shù):<asp:Label ID="lblShowTextLength" runat="server" Text="0" ForeColor="Red"></asp:Label><br />
</th>
<td style="text-align: left;">
<FCKeditorV2:FCKeditor ID="fckPrdDescription" runat="server" Height="240px" Width="100%">
</FCKeditorV2:FCKeditor>
</td>
</tr>

JS代碼:
復(fù)制代碼 代碼如下:

<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance)
{
var oEditor = FCKeditorAPI.GetInstance('fckPrdDescription');
oEditor.EditorDocument.body.onkeyup=function ()
{
if( document.all)
{
$("lblShowTextLength").innerText =oEditor.EditorDocument.body.innerText.length;
}
else
{
var r = oEditor.EditorDocument.createRange() ;
r.selectNodeContents( oEditor.EditorDocument.body ) ;
$("lblShowTextLength").innerText= r.toString().length ;

}
if(parseInt($("lblShowTextLength").innerText)>100)
{
alert("當前已經(jīng)達到100中文字,請不要繼續(xù)輸入!");
oEditor.EditorDocument.body.innerText=oEditor.EditorDocument.body.innerText.substring(0,100);
$("lblShowTextLength").innerText =oEditor.EditorDocument.body.innerText.length;
}
// $("ddd").value =oEditor.EditorDocument.body.innerHTML;
}
if (document.getElementById("hidStatus").value=="Cancel")
{
editorInstance.EditorDocument.designMode="off";
}
}
</script>

演示:
輸入多馀100個字符數(shù) 提示

點擊【確定】后 自動截取100個字符

相關(guān)文章

最新評論

兴国县| 区。| 常德市| 宣城市| 桑植县| 岗巴县| 庆城县| 弥勒县| 泸水县| 阿合奇县| 左权县| 新竹市| 芷江| 克拉玛依市| 宁都县| 汽车| 曲靖市| 屯昌县| 芜湖县| 抚顺市| 什邡市| 鞍山市| 临澧县| 兴隆县| 沅陵县| 青龙| 黄冈市| 清原| 汝南县| 武山县| 个旧市| 嘉定区| 铜梁县| 依兰县| 永新县| 德昌县| 同德县| 抚州市| 饶平县| 清涧县| 桦甸市|