“执行insertHtml命令时出错";当在“查看源代码"中插入html时,cleditor中会显示一条消息.模式 [英] "Error executing the insertHtml command" message in cleditor when inserting html in "View Source" mode
问题描述
我到处都在寻找解决方案,但没有找到答案,所以您是我最后的希望,Stackoverflow ...
I've searched for the solution for this everywhere and have not found an answer, so you're my last hope, Stackoverflow...
关于cleditor,有人知道如何使查看源代码"模式下的"inserthtml"命令起作用吗?
With regard to cleditor, does anybody know how to make the "inserthtml" command in "View Source" mode work?
当前,我有一个附加到按钮的onclick处理程序上的方法,该方法将字符串插入cleditor的textarea:
Currently, I have a method attached to a button's onclick handler that inserts a string into the cleditor's textarea:
editor.focus();
setTimeout(function() { editor.execCommand('inserthtml', stringToInsert); }, 0);
上面的代码在普通的RTF模式下可以正常工作,但是如果您尝试在查看源代码模式下执行它,则会发生以下情况:
The above works fine in the normal Rich Text mode but if you try to execute it while in View Source mode, the following will happen:
- 在Firefox中,它弹出一则小消息,提示执行错误 inserthtml命令."
- 在Chrome中,它会静默失败
- 在IE中:
- 如果文本区域为空,则在Visual Studio中的"y(a).pasteHTML(c)"处出现断点,其外观类似于jquery.cleditor.min.js,并显示以下消息:"Microsoft JScript运行时错误:未指定的错误."
- 如果textarea已经包含文本,则在同一文件中的"a.range [0] .select()"处命中断点,并显示以下消息:"Microsoft JScript运行时错误:由于错误而无法完成操作800a025e."
- In Firefox, it pops up a little message that says "Error executing the inserthtml command."
- In Chrome, it fails silently
- In IE:
- If the textarea was empty, I hit a breakpoint in Visual Studio at "y(a).pasteHTML(c)" in what looks like jquery.cleditor.min.js, with the following message, "Microsoft JScript runtime error: Unspecified error."
- If the textarea already contained text, I hit a breakpoint at "a.range[0].select()" in the same file with the following message, "Microsoft JScript runtime error: Could not complete the operation due to error 800a025e."
推荐答案
hi i think it is very simmilar problem as here
我假设您粘贴的代码是在按钮单击功能中执行的 在此功能末尾,只需添加
i assume that code pasted by you is executed in button click function at the end of this function just add
返回假;
添加类似的东西:
功能someClick(e,data){
function someClick(e, data) {
// Get the editor var editor = data.editor; editor.focus(); setTimeout(function() { editor.execCommand('inserthtml', stringToInsert); }, 0); return false;
}
是的,这并不是一件容易的事:当您处于正常模式时,您的文本区域实际上就是iframe;当您处于源代码模式时,您的文本区域又变成了文本区域,以便在其中编辑数据可以通过
yep you are right it is not so easy : when yo are in normal mode your text area is actualy iframe when you are in source mode your textarea is again becomeing textarea so to edit data inside you can get it by
$('#mytextarea').val()
如果您想在末尾附加一些内容,可以使用:
if you want to append something at the end you can use :
setTimeout(function() {$('#mytextarea').val($('#mytextarea').val()+'aaaaa') }, 3000);
if you want to insert at current ursor cosition this should help : Cursor position in a textarea (character index, not x/y coordinates)
这篇关于“执行insertHtml命令时出错";当在“查看源代码"中插入html时,cleditor中会显示一条消息.模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!