这两天做一个关于新闻管理方面的项目 需要在线编辑系统 以前没搞过类似的东东 只好再网上找 大家推荐的是 ckeditor 相关的
说明也很多下面是一种对配置简单的做法
在已用的时候大致
配置方法 : 是从 http://blog.csdn.net/guoquanyou/article/details/6754990 复制过来的 是在jsp中得使用方法 可以说是比
较简洁的 而且兼容性比较好的
另外如果想去掉没用的工具栏的话 在onload方法里修改成以下代码
window.onload = function(){
CKEDITOR.replace('form1:content' , { toolbar:[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
['BidiLtr', 'BidiRtl'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks','-','About']
]
});
不想要那个工具就删除相应的 工具 就o啦
这里主要是说在jsf页面严正的时候 因为inputtextarea 标签会给 textarea标签包装一下 比如
<h:form id="form1" >
<h:inputTextarea styleClass="input_no_width" value="#{lowAdd.low.content}" id="content"></h:inputTextarea>
<h:commandButton type="submit" οnclick="return test()" value="添加" styleClass="btn" action="#
{lowAdd.addLow}" id="tianjia"></h:commandButton>
</h:form>
在jsf展示的时候 回 把 id="content" 的id 替换成 id="form1:content"
并且如果用document.getElementById('form1:content').value 是得不出来的
在js验证页面内容的时候
function check() {
submitflag = true;
var editor_data = CKEDITOR.instances[0].getData();
//var editor_data = CKEDITOR.instances['form1:content'].getData(); //这样也可以
var content= document.getElementById('form1:content').value = editor_data;
if (content =='') {
alert('内容不能为空');
submitflag = false;
return false;
}
return true;
}