关于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);
高分送上,请速回复
...全文
1482 39 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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)

87,997

社区成员

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

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