<textarea id="content" name="content" style="display:none"></textarea>
<iframe id="myEditor" src="Edit/editor.htm?id=contentReadCookie=1" frameborder="0" scrolling="no" width="621" height="457"></iframe>
-----
这是编辑器,编辑器内有插入图片的可以使用,但是我想在编辑器外另外弄一个单独的图片上传,代码如下:
<iframe id='UpPhotoFrame' name='UpPhotoFrame' src='User_UpFile.asp?ChannelID=1' frameborder="0" scrolling="No" align="center" width='100%' height='30'></iframe>
通过这个iframe上传的图片如何能插入到上述编辑器光标所在位置?我在图片上传成功后使用insertHTMLToEditor(imgurl)返回了图片地址,那么问题是我尝试了很多种方式,都不能在编辑器内使用insertHTMLToEditor这个JS函数成功插入到光标所在,请高手指教。谢谢
<iframe id="myEditor" src="Edit/editor.htm?id=contentReadCookie=1" frameborder="0" scrolling="no" width="621" height="457"></iframe>
-----
这是编辑器,编辑器内有插入图片的可以使用,但是我想在编辑器外另外弄一个单独的图片上传,代码如下:
<iframe id='UpPhotoFrame' name='UpPhotoFrame' src='User_UpFile.asp?ChannelID=1' frameborder="0" scrolling="No" align="center" width='100%' height='30'></iframe>
通过这个iframe上传的图片如何能插入到上述编辑器光标所在位置?我在图片上传成功后使用insertHTMLToEditor(imgurl)返回了图片地址,那么问题是我尝试了很多种方式,都不能在编辑器内使用insertHTMLToEditor这个JS函数成功插入到光标所在,请高手指教。谢谢
if(document.all)
{
editwindow.focus();
var t = editwindow.document.selection.createRange();
t.moveStart("textedit");
t.moveEnd("textedit");
t.select();
editwindow.document.selection.createRange().pasteHTML(myHTML + " ");
}
else
{
editwindow.document.execCommand("insertHTML", false, myHTML + " ");
}
编辑器的输入焦点问题
http://topic.csdn.net/u/20071108/16/611485de-72ce-4eef-a641-9071f0b0b453.html
HTML编辑器失去焦点后在原来光标位置插入信息/图片
function insertHTMLToEditor(codeStr)
{
var isIE=!!document.all
var editor = document.getElementById('HtmlEdit').contentWindow.EDiaryEditor;
var content = editor.iframe.contentWindow;
//alert(editor.iframe.id);
if(isIE) {
try{
content.focus();
var oRng = content.document.selection.createRange();
oRng.pasteHTML(codeStr);
oRng.collapse(false);
oRng.select();
}
catch(e){}
}
else {
editor.iframe.execCommand('insertHTML', false, codeStr);
}
} 结贴,散分