[英]informal text to Html in CKEDITOR
i have String Like As below : 我有如下字符串:
alert(tempstr);//"<b> Testing </b>"
now I want create a ckeditor node with this string 现在我想用这个字符串创建一个ckeditor节点
NewElem=CKEDITOR.dom.element.createFromHtml(tempstr);
or 要么
NewElem.setHtml(tempstr);
Both are Assigning just as a Text. 两者都作为文本进行分配。
may be using replace ( <
to < ) and ( >
to>) is possible.my thought is that is not a proper code. 可能使用replace(
<
to <)和( >
to>)。我认为这不是正确的代码。 Any Other proper code to Assign as Html string?. 还有其他要分配为HTML字符串的适当代码吗?
Both methods accept HTML, not an encoded HTML. 两种方法都接受HTML,而不接受编码的HTML。 So you should find a way to decode HTML in
tempstr
. 因此,您应该找到一种在
tempstr
解码HTML的tempstr
。 The easiest solution is to use replace method: 最简单的解决方案是使用替换方法:
var newElement = CKEDITOR.dom.element.createFromHtml(
tempstr.replace( /</gi, '<' ).replace( />/gi, '>' )
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.