我在文本框(content)中添加了内容,我alert(content);出的东西依然是空的,也就是我用普通的方式拿不到文本编辑器(fck:editor)中的内容。
如下的编辑器 内容:<fck:editor id="content" basePath="${pageContext.request.contextPath}/fckeditor/"
customConfigurationsPath="${pageContext.request.contextPath}/fckeditor/myconfig.js"
toolbarSet="Customer" width="100%" height="400">
</fck:editor>我用通常的方式(javascript函数)(如下)获取不到值:
var content = document.getElementById("content");
alert(content.value);
if (content.value == '')
{
alert("添加公告内容不能为空,请添加!");
content.focus();
}else{
document.form1.submit();
}
这样试试 。
var ret = document.getElementById("content").innerHTML;
if(typeof(FCKeditorAPI) !== 'undefined'){
oEditor = FCKeditorAPI.GetInstance("content");
}
try{
ret = oEditor.GetXHTML(true)
}catch(e){
return "";
}
return ret;
}
这样试试