Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 需要NicEdit解决方案将HTML文本插入实例_Javascript_Html_Wysiwyg_Nicedit - Fatal编程技术网

Javascript 需要NicEdit解决方案将HTML文本插入实例

Javascript 需要NicEdit解决方案将HTML文本插入实例,javascript,html,wysiwyg,nicedit,Javascript,Html,Wysiwyg,Nicedit,我正在使用此函数将文本插入NicEdit function insertAtCursor(editor, value){ var editor = nicEditors.findEditor(editor); var range = editor.getRng(); var editorField = editor.selElm(); editorField.nodeValue = editorField.nodeValue.substring(0, ra

我正在使用此函数将文本插入NicEdit

function insertAtCursor(editor, value){
var editor = nicEditors.findEditor(editor);
var range = editor.getRng();                    
var editorField = editor.selElm();
editorField.nodeValue = editorField.nodeValue.substring(0, range.startOffset) +
                        value +
                        editorField.nodeValue.substring(range.endOffset, editorField.nodeValue.length);}
此代码适用于简单文本,但当我向其中传递HTML内容时,它不会在div中呈现HTML输出,而是将HTML代码按原样转储到实例div中。

示例:

这里有一些文本
这必须在实例中显示为“此处的某些文本” 以及隐藏在源代码中的其余代码


有谁能给我一个解决这个问题的方法吗?

在工作了一整晚并尝试了不同的解决方案之后,我终于让它工作起来了!:)

如果有人想知道这个问题的解决方案,我必须添加一个Replace函数

replace()

内容,并使其支持HTML。

请参阅我的答案。这是我创建的一个插件,用于在光标位置插入html。

面临类似问题……请详细说明一下?我的代码if(this.options.command=='InsertBookmark'){var editor=nicEditors.findEditor(“cpMain_area2”);var range=editor.getRng();var editorField=editor.sellem();alert(A);if(editorField.nodeValue==null){//editorField.setContent(“+A+”)editorField.replacew(A);//editorField.replace(A,“
”);//editorField.insertBefore(“tEST”,editor.sellem())}
replace()