修改文章时,大家是怎样将内容载入FCKeditor的??
我这样
varoFCKeditor=newFCKeditor('content');
oFCKeditor.BasePath='/fckeditor/';
oFCKeditor.ToolbarSet='Default';
oFCKeditor.Width='100%';
oFCKeditor.Height='600';
oFCKeditor.Value='
<%=rs(content)%>';
oFCKeditor.Create();
问题多多啊,由于一些符号的原因,经常导致编辑器无法创建,或者载入的内容跑编辑器外面来了!
应该使用这个函数,但是这个是用在客户端的,服务器上的内容如何能传能它呢!!!
functionSetEditorContents(EditorName,ContentStr)
{
varoEditor=FCKeditorAPI.GetInstance(EditorName);
oEditor.SetHTML(ContentStr);
}
---------------------解决方案------------------------------
---------------------解决方案------------------------------
直接给fck赋值不就OK了
---------------------解决方案------------------------------
怎样直接赋值啊,是我问题中那样吗?oFCKeditor.Value = ' <%=rs(content)%>' ;
这种方法问题多多啊,由于一些符号(如'和一些未知)的原因,经常导致编辑器无法创建,或者载入的内容跑编辑器外面来了!
---------------------解决方案------------------------------
<%
dim tmpstr
tmpstr=rs.fields("content")
tmpstr=replace(tmpstr,"'","\'")
tmpstr=replace(tmpstr,chr(13),"")
tmpstr=replace(tmpstr,chr(10),"")
%>
oFCKeditor.Value = '<%=tmpstr%>'
---------------------解决方案------------------------------
把回车换行都换成空格啊!这些都是源代码里的回车换行而不是按制页面显示的换行吧,但是即是源代码的里的也不能随便换成空格吧,我遇到过这样的问题,将一个JS的注释后的源代码换行去掉了,接果后面的代码与省政府释连到了一起,导致后面的一段代码无法执行了!
而且JS创建时同样的处理有用吗?都说JS创建问题更多!
---------------------解决方案------------------------------
oFCKeditor.Value='?'
中的内容不能有单引号,如果有单引号需要使用"\'"替代,?中的内容不能有回车换行符,如果有回车换行符要用"\n"替代,其实这些都是javascript的基础
---------------------解决方案------------------------------
我将单引号换成基ASCII码'可以吗?(这样不用再转换回来,直接显示成单引号!我试了下好像可以,有时双不可以(不过此时可能是有回车换行符造成的)
---------------------解决方案------------------------------
asp中回车换行符不能用用"\n"替代吗??只能换成空吗?
---------------------解决方案------------------------------
测试了一下,换成空或\r \n都可以,谢谢!
---------------------解决方案------------------------------
oFCKeditor.Value='?'
如果?内容是用FckEditor录入的,fckeditor会自动把回车换行符替换成<br>标记,所以一般情况替换成空并不会有什么问题,除非?内容不是用FckEditor录入的,那可以替换成"\n",在javascript里面"\n"就是回车换行符。之所以要替换回车换行符是因为?的内容不能分行,如果分行了就会变成了下面这种情况:
oFCKeditor.Value='123
'
这肯定有问题,所以必须把回车换行符替换掉。
同样的道理单引号也必须替换,如果不替换就会出现下面这种情况:
oFCKeditor.Value='123''
这肯定也是有问题的,改成oFCKeditor.Value='123\''就没问题了。
oFCKeditor.Value='?' 这是一个javascript的赋值语句,必须符合javascript的语法规则
---------------------解决方案------------------------------
在 jsp 我这样作行得通:
<%
Information news = (Information)request.getAttribute("news");
String context = news.getContext();
String tempContext = context.replace("'","\'");
tempContext = context.replaceAll("\r\n","<br>");
%>
-----------------------------------------------------------------------------------
<script type="text/javascript">
var oFCKeditor = new FCKeditor('context');
oFCKeditor.BasePath='resources/fckeditor/';
oFCKeditor.Height='450px'; oFCKeditor.Width='800px'; oFCKeditor.ToolbarSet='DefaultNoForm';
oFCKeditor.Value = ' <%=tempContext%>' ;//默认值
oFCKeditor.Create();
</script>
---------------------解决方案------------------------------
我的解决方案是:
1)把要在FCKEdit中显示的信息先放在hiden 里面,再在JS中获取赋值:代码如下:
<@s.hidden id="productDescriptionId" value="${tempProduct?if_exists.productDescription!''}" />
<script type="text/javascript">
var DescriptionStyle = $('#productDescriptionId').val();
if (DescriptionStyle == undefined || $.trim(DescriptionStyle) == '') {
DescriptionStyle = ' ';
}
var sBasePath = '${base}/fc/' ;
var oFCKeditor = new FCKeditor( 'productDescription' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Width = 668 ;
oFCKeditor.Height = 250 ;
oFCKeditor.Value = DescriptionStyle;
oFCKeditor.ToolbarSet = "Product" ;
oFCKeditor.Create() ;
</script>