Javascript CKEditor中的insertHTML不仅适用于图像

Javascript CKEditor中的insertHTML不仅适用于图像,javascript,jquery,ckeditor,Javascript,Jquery,Ckeditor,我已尝试使用以下代码将上载的图像插入到CKEditor中 var editor = CKEDITOR.instances.writearticle; var value = '<img src="images/imagename.jpg">'; editor.insertHtml( value ); var editor=CKEDITOR.instances.WriteAttribute; var值=“”; 编者:insertHtml(值); 但这是行不通的。但是当我尝试用同样的

我已尝试使用以下代码将上载的图像插入到CKEditor中

var editor = CKEDITOR.instances.writearticle;
var value = '<img src="images/imagename.jpg">';
editor.insertHtml( value );
var editor=CKEDITOR.instances.WriteAttribute;
var值=“”;
编者:insertHtml(值);
但这是行不通的。但是当我尝试用同样的逻辑来处理这段代码时

var editor = CKEDITOR.instances.writearticle;
var value = '<strong>Hello World</strong>';
editor.insertHtml( value );
var editor=CKEDITOR.instances.WriteAttribute;
var值=“你好世界”;
编者:insertHtml(值);
Hello world插入粗体文本。为什么它不适用于
标记


我在这个网站上找到了这个程序和插入工作。我的站点出现了什么问题?

添加

config.allowedContent = 'img[src,alt,width,height]'; // But be sure to add all the other tags you use in with your Editor. Tags except this will be disabled.
替代溶液

config.extraAllowedContent='img[src,alt,width,height]'

这将把
属性添加到允许的标记列表中,在这里您需要指定需要允许的每个标记。-积分:


在config.js文件中。

您也可以在此处写入允许的内容,而不是修改配置

editor.addCommand( 'XXXDialog', new CKEDITOR.dialogCommand( 'XXXDialog', { allowedContent : 'img[src,alt,width,height]'}) );

就我而言,我刚刚补充说:

config.allowedContent = true;
在编辑器配置中


它解决了这个问题。

可以在html页面上看到图像标签吗?如果是,请检查图像路径是否正确。@Nitinvarpe:No未插入
。但对于其他标记,如
则可以正确插入。检查这个链接哦,伙计!!无需言语表达我的感谢:)欢迎您,我的荣幸如果您不想列出所有其他标记以便它们不会被禁用,只需使用
config.extraAllowedContent='img[src,alt,width,height]