小孔子的快乐生活

fckeditor在.net中的使用

很多人问我fckeditor怎么实现自动添加标题图片,其实很简单,只要找到fckeditor的上传函数就搞定了,我也想不起来在哪个文件里了,我简单的说一下吧.
    在web.config里加上下面这段:

<appSettings>
    
<add key="FCKeditor:BasePath" value="~/fckEditor/"/>
    
<add key="FCKeditor:UserFilesPath" value="/news/UserFiles" />
</appSettings>

上面的FCKeditor:BasePath指的是fckeditor的路径,我写的是"~/fckEditor/",就是在根目录下的fckeditor文件夹里,这里可以用"~",但是下面的"FCKeditor:UserFilesPath" 就不能用"~"了,为什么?因为第一个是让程序找到fckeditor,asp.net肯定知道"~"是什么意思了,但下面的这个是让fckeditor知道上传文件的位置,fckeditor是用js写的,所以它当然不知道"~"是什么意思了.呵呵
    怎么实现自动添加标题图片?
在我提供的文件里找到fckconfig.js文件,打开看一下最后的函数:

FCKConfig.setUploadImg = function(_res)
    
if(!_res) return;
    objDrop
=parent.document.getElementById("upimgSelect");
    objText
=parent.document.getElementById("txtUpImg");
    
var nIndex = objDrop.selectedIndex;
    
if(objDrop.options[0].value=="")objDrop.options[0]=null;
    
var oLen=objDrop.length;
    
if(oLen>0)
    
{
     
for(var i=0; i<oLen; i++){
         
if(objDrop.options[i].value==_res) return;
     }

 }

 objDrop.options[oLen] 
= new Option('Image'+[oLen+1], _res);
 objDrop.selectedIndex 
= nIndex;
 
if(objText.value=="" || objText.value.length==0)objText.value=_res;
}

上面的"upimgSelect"是个下拉框,用于存放所有上传图片,"txtUpImg"是个文本框,用于显示选中的图片地址,也就是说你在编辑文章的页面里面要加这两个东西
    就说这些吧,希望有用

posted on 2007-04-28 10:39  小孔子  阅读(2986)  评论(5编辑  收藏  举报

导航