javascript-如何在代码编辑器中显示多个文本区域(我的一个尝试是使用CKEditor)
我在项目中使用jquery和CKEditor。我希望用户可以在CKEditor中编写/编辑他们的html代码。 当我在编辑器中输入多个textarea标记时,它们看起来很好,因为它们都位于textarea内,如下所示 然后我保存了它,我确认它保存正确,因为我检查了文件中的源代码 但是,如果我再次在CKEditor中打开该文件,它将无法正确显示,如下所示: 下面是我使用的示例代码。但这并不是完整的代码javascript-如何在代码编辑器中显示多个文本区域(我的一个尝试是使用CKEditor),javascript,ckeditor,textarea,wcm,web-content,Javascript,Ckeditor,Textarea,Wcm,Web Content,我在项目中使用jquery和CKEditor。我希望用户可以在CKEditor中编写/编辑他们的html代码。 当我在编辑器中输入多个textarea标记时,它们看起来很好,因为它们都位于textarea内,如下所示 然后我保存了它,我确认它保存正确,因为我检查了文件中的源代码 但是,如果我再次在CKEditor中打开该文件,它将无法正确显示,如下所示: 下面是我使用的示例代码。但这并不是完整的代码 <textarea id="eidtArea" name="editScr
<textarea id="eidtArea" name="editScriptContent"><!--Load the saved file here (I will skip this part here)--></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'eidtArea');
</script>
CKEDITOR.replace('eidtArea');
我的问题是:
- 我是否错过了在这个插件中设置任何东西,或者是否有解决方法 你能做什么
- 事实上,我真的不需要使用这个插件。我可以简单地使用textarea让用户编辑代码。基本上是我想 使用此插件是因为我希望用户可以在中创建textarea标记 编辑。但是,如果我只是使用textarea标记作为编辑器,他们就不能在这个编辑器中添加任何其他textarea标记。这种方法是否有解决办法?如果是这样,那么在这种情况下我确实需要使用CKEditor
中打印HTML之前,必须对其进行编码。否则,您的后端将产生以下结果:
<textarea id="editor">
<p>Some text: <textarea>foo</textarea></p>
<p>Some text: <textarea>bar</textarea></p>
</textarea>
一些文字:foo
一些文本:bar
浏览器会将其解析为:
<textarea id="editor">
<p>Some text: <textarea>foo
</textarea>
// And here the rest of the content of the editor,
// but outside the editor's textarea
一些文字:foo
//这里是编辑的其他内容,
//但是在编辑的文本区域之外
因此,您至少需要替换所有