live2k说的和我想得一样,但是之前我将焦点落回到编辑器中,如楼顶代码1,3 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); win.focus();这句是起作用的,没有这句插入不了任何内容,但是,插入的位置不对。
风之石所说的我早先已经测试过。内容是有的,内容也可以插入,但是插入点有问题,总是在内容的开始。
例如:abcdef我要在f后或者在c后插入<img src="..." />一段内容,但是不可以,插入的内容会在a前面。我试着找了一下原因,发现,如果我在上传的同时,如果能把光标移动到我想要的位置上,那么就可以达到预期的效果,如果,我没有去做上述一步,那么插入的内容就会在所有内容之前。
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);
win.focus();这句是起作用的,没有这句插入不了任何内容,但是,插入的位置不对。
我说楼上的,你不是开玩笑吧,你一天能做出一个fckeditor?
oEditor.InsertHtml('内容')
这有什么奇怪的...
刚开始是0
以后就是x集拼接...
然后熟悉了就容易了,,,,
你以为每次都重写呀..........
-----------------------------------X问题是我不能等到n^m年后再用x的拼集
这个我试过了,图片只能插入在内容得最前面,虽然可以粘贴复制到需要的位置,但是我认为很不爽,现在我用这种方法解决了:
我将图片文件上传的提交按钮放到了FCKeditor所在的页面内,没有和表单放在同一文件中,这样就可以暂时解决上传以后焦点错误的问题。
但是我不认为这是一种好办法,所以期待大家的答案
另外400分依然有效。
我在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) ;
}
http://www.xidea.org/project/jsi/test/fckeditor/_samples/html/sample08.html
那种情况我知道,问题现在是在iframe 中,请亲自测试
if(oEditor.EditorWindow){
oEditor.InsertHtml(codeStr);
}最新版的FCK
在编辑器所在的页面添加一个函数
function insertHTMLToEditor(codeStr)
{
oEditor=FCKeditorAPI.GetInstance('content');
if(oEditor && oEditor.EditorWindow){
oEditor.InsertHtml(codeStr);
}
}在iframe中调用parent.insertHTMLToEditor(codeStr);