关于FCKEditor编辑器外向编辑器内插入内容的问题(内祥)

什么都不能 2007-07-26 09:30:54
今天把FCKEditor中的媒体上传功能禁掉,要从编辑器外面向编辑器内插入(图片,Flash等)内容。发现一向很灵的方法失效了,想请教一下大家有何高招。
我的方法如下:
1)var oEditor=parent.FCKeditorAPI.getInstance("content");
var win=oEditor.EditorWindow;
win.focus();
var doc=oEditor.EditorDoument;
var rng=doc.selection.createRange();
rng.pasteHTML(myHtml);
2) var oEditor=parent.FCKeditorAPI.getInstance("content");
oEditor.insertHtml(myHtml);
3) var iframe_1=parent.document.frames["Frames___content"];
var iframe_2=iframe_1.document.frames[0]; //编辑器的编辑区
var win=iframe_2.contentWindow;
var doc=iframe_2.contentWindow.document;
win.focus();
var rng=doc.selection.createRange();
rng.pasteHTML(myHtml);
高分送上,请速回复
...全文
1493 39 打赏 收藏 转发到动态 举报
写回复
用AI写文章
39 条回复
切换为时间正序
请发表友善的回复…
发表回复
longhumeng 2010-09-03
  • 打赏
  • 举报
回复
好,这个要标记一下!
yy8616270 2008-10-06
  • 打赏
  • 举报
回复
不错。~很好的。
haodan969 2007-11-23
  • 打赏
  • 举报
回复
英雄所见略同,我用跟你一样的方法做出来了:)
什么都不能 2007-08-21
  • 打赏
  • 举报
回复
请到http://community.csdn.net/Expert/topic/5678/5678132.xml?temp=.6486322拿分
什么都不能 2007-08-21
  • 打赏
  • 举报
回复
测试成功。Gdj400分
什么都不能 2007-08-20
  • 打赏
  • 举报
回复
好,我验证一下,这两天忙,这个给耽搁了。我测试成功就结贴
shili150 2007-08-20
  • 打赏
  • 举报
回复
jf
Gdj 2007-08-10
  • 打赏
  • 举报
回复
用2.4.3版测试如下:
在编辑器所在的页面添加一个函数
function insertHTMLToEditor(codeStr)
{
oEditor=FCKeditorAPI.GetInstance('content');
if(oEditor && oEditor.EditorWindow){
oEditor.InsertHtml(codeStr);
}
}

在iframe中调用parent.insertHTMLToEditor(codeStr);
什么都不能 2007-08-10
  • 打赏
  • 举报
回复
请楼上的仁兄标明版本以便测试,谢谢合作。
Gdj 2007-08-09
  • 打赏
  • 举报
回复
oEditor=FCKeditorAPI.GetInstance('content');
if(oEditor.EditorWindow){
oEditor.InsertHtml(codeStr);
}

最新版的FCK
什么都不能 2007-08-03
  • 打赏
  • 举报
回复
dh20156(风之石) ( ) 信誉:4
那种情况我知道,问题现在是在iframe 中,请亲自测试
dh20156 2007-08-02
  • 打赏
  • 举报
回复
楼主可以参考一下这里:
http://www.xidea.org/project/jsi/test/fckeditor/_samples/html/sample08.html
uuq 2007-08-01
  • 打赏
  • 举报
回复
你可以看下fck扩展
我在phpx看到
------------------------------------------
//获取格式化的编辑器内容
function getEditorContents(){
var oEditor = FCKeditorAPI.GetInstance("content");
alert(oEditor.GetXHTML(true));
}
//就上面这个函数可以取到值,
-------------------------------------------------------------------------
下面的是其它操作FCK的方法,一起贴过来

//向编辑器插入指定代码
function insertHTMLToEditor(codeStr){
var oEditor = FCKeditorAPI.GetInstance("content");
if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){
oEditor.InsertHtml(codeStr);
}else{
return false;
}
}
//统计编辑器中内容的字数
function getLength(){
var oEditor = FCKeditorAPI.GetInstance("content");
var oDOM = oEditor.EditorDocument;
var iLength ;
if(document.all){
iLength = oDOM.body.innerText.length;
}else{
var r = oDOM.createRange();
r.selectNodeContents(oDOM.body);
iLength = r.toString().length;
}
alert(iLength);
}
//执行指定动作
function ExecuteCommand(commandName){
var oEditor = FCKeditorAPI.GetInstance("content") ;
oEditor.Commands.GetCommand(commandName).Execute() ;
}
//设置编辑器中内容
function SetContents(codeStr){
var oEditor = FCKeditorAPI.GetInstance("content") ;
oEditor.SetHTML(codeStr) ;
}
什么都不能 2007-08-01
  • 打赏
  • 举报
回复
回复:mayi545()
这个我试过了,图片只能插入在内容得最前面,虽然可以粘贴复制到需要的位置,但是我认为很不爽,现在我用这种方法解决了:
我将图片文件上传的提交按钮放到了FCKeditor所在的页面内,没有和表单放在同一文件中,这样就可以暂时解决上传以后焦点错误的问题。
但是我不认为这是一种好办法,所以期待大家的答案
另外400分依然有效。
什么都不能 2007-08-01
  • 打赏
  • 举报
回复
btbtd(转型(L/C)AMP) ( ) 信誉:100 2007-07-31 12:05:45 得分: 0


这有什么奇怪的...
刚开始是0
以后就是x集拼接...
然后熟悉了就容易了,,,,
你以为每次都重写呀..........

-----------------------------------

X问题是我不能等到n^m年后再用x的拼集
btbtd 2007-07-31
  • 打赏
  • 举报
回复
这有什么奇怪的...
刚开始是0
以后就是x集拼接...
然后熟悉了就容易了,,,,
你以为每次都重写呀..........
什么都不能 2007-07-31
  • 打赏
  • 举报
回复
我要的功能很复杂7天?,2天,1天。
我说楼上的,你不是开玩笑吧,你一天能做出一个fckeditor?
mayi545 2007-07-31
  • 打赏
  • 举报
回复
var oEditor = parent.FCKeditorAPI.GetInstance('content')
oEditor.InsertHtml('内容')
btbtd 2007-07-30
  • 打赏
  • 举报
回复
自己写花不了几天时间...
时间参考...
第一个 7 天
第二个 2天
第三个 1天....
什么都不能 2007-07-30
  • 打赏
  • 举报
回复
自己搞个要到何年哪月啊?
加载更多回复(19)
此文档的目录结构: 1 FCKeditor的下载及介绍 4 1.1 下载地址 4 1.2 FCKeditor下载包的介绍 4 2 FCKeditor的目录和文件精简 4 3 在页面创建FCKeditor 4 3.1 Js创建FCKeditor实例: 4 3.1.1 方法一:内嵌方法(推荐) 4 3.1.2 方法二:替换页面中的Textarea 5 3.1.3 方法三:适合于Ajax的调用方法 6 3.1.4 Js中FCKeditor对象的属性(集合)和方法 6 3.1.4.1 属性 6 3.1.4.2 集合 7 3.1.4.3 方法 7 3.1.5 FCKeditor的JS构造器 9 3.1.6 将从后台读取的数据显示在FCKeditor中 9 3.2 在Jsp中通过自定义标签创建: 9 3.3 FCKeditor API 调用 10 3.4 适时打开编辑器 10 4 修改FCKeditor的配置: 11 4.1 方法一:修改fckconfig.js 文件 11 4.2 方法二:使用一个额外的配置文件覆盖默认配置 11 4.3 配置的加载顺序 11 4.4 提示 11 4.5 一般需要修改的配置项 11 4.5.1 默认语言 11 4.5.2 自定义ToolbarSet, 去掉一些不需要的功能 12 4.5.3 加上几种常用的字体 13 4.5.4 修改“回车” 和 “Shift + 回车”的换行行为 13 4.5.5 修改编辑区的样式文件 14 4.5.6 更换表情图片 14 4.5.7 编辑区域的右键菜单功能 14 4.6 fckconfig.js配置参数选项说明 15 4.7 自定义工具栏按钮 17 4.8 自定义右键菜单 18 5 文件上传问题 19 5.1 开启和关闭文件上传功能(fckconfig.js) 19 5.2 文件上传的基本使用 19 5.3 上传中文文件名的文件会出现乱码 20 5.4 创建中文名目录会出现乱码 21 5.5 引用中文名文件的图片不能正常显示 21 5.6 控件允许上传的文件的类型 22 5.7 控制上传的文件的大小 22 5.8 增加文件删除功能 23 6 超连接重定位问题 25 7 使用FCKeditor的API 26 7.1 获得FCKeditor的实例 26 7.1.1 获得当前页FCKeditor实例 26 7.1.2 从FCKeditor的弹出窗口中获得FCKeditor实例 26 7.1.3 从框架页面的子框架中获得其它子框架的FCKeditor实例 26 7.1.4 从页面弹出窗口中获得父窗口的FCKeditor实例 26 7.2 常见的Js方法调用 27 7.2.1 插入HTML到FCKeditor 27 7.2.2 设置FCKeditor内容(HTML) 27 7.2.3 获取FCKeditor中的XHTML 27 7.2.4 获取FCKeditor中的innerHTML和innerText 27 7.2.5 执行指定动作 28 7.2.6 统计编辑器内容的字数 29 7.2.7 检查FCKeditor中的内容是否有改动 29 7.2.8 将FCKeditor中的内容是否有改动的值重新设置 29 8 外联编辑条(多个编辑域共用一个编辑条) 29 9 解释fck样式(CSS)的工作原理 30 10 获取FCKeditor插入的图片 31

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧