当前位置:软件学习 > Dreamweaver >>

设置fck焦点及获取fck编辑器内容 长度 js代码

设置fck焦点及获取fck编辑器内容 长度 js代码
本教程主要讲了怎么利用js 来设置编辑器获得焦点获取fck编辑器内容判断是否为空,以及内容长度与js调用fck编辑器的方法。

var checkcontent =fckeditorapi.getinstance("content").getxhtml();


写成函数

function geteditorhtmlcontents(editorname) {
var oeditor = fckeditorapi.getinstance(editorname);
return(oeditor.getxhtml(true));


编辑器获得焦点

var oeditor = fckeditorapi.getinstance('content');  
oeditor.focus(); 

写成函数

// 设置编辑器焦点

function seteditorcontents(editorname, contentstr) {
var oeditor = fckeditorapi.getinstance(editorname) ;
oeditor.focus;
}

上面方法简单写

长度验证:
fckeditorapi.getinstance("content").getxhtml().length;
另外还要让编辑器获得焦点:

var oeditor = fckeditorapi.getinstance('content');oeditor.focus();


fckeditor js调用方法

<script src="fckeditor/fckeditor.js"></script>
<script type="text/网页特效">
<!--
function showfck(){
var ofckeditor = new fckeditor('content') ;
ofckeditor.basepath = 'fckeditor/' ;
ofckeditor.toolbarset = 'basic' ;
ofckeditor.width = '100%' ;
ofckeditor.height = '200' ;
ofckeditor.value = '' ;
ofckeditor.replacetextarea() ;
document.getelementbyid("btnshow").disabled = 'true';
document.getelementbyid("btnshow").style.display = 'none';

}
//-->
</script>
<textarea name="content"></textarea>
<input id=btnshow style="display:inline" type=button onclick="showfck()">

fck推荐下载地址

http://down.zhaoxi.net/webedit/2009/0429/fck-dedecms.html

 

补充:网页制作,Dreamweaver 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,