javascript 如何安装CKeditor
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15222635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install CKeditor
提问by thomas-hiron
I don't know how to install CKeditor, I downloaded the editor on the website and then put the following code between my head tags :
我不知道如何安装CKeditor,我在网站上下载了编辑器,然后将以下代码放在我的head标签之间:
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor1 = new CKEDITOR('message');
oFCKeditor1.ToolbarSet = 'Basic' ;
oFCKeditor1.BasePath = "ckeditor/" ;
oFCKeditor1.ReplaceTextarea() ;
}
</script>
But the line below returns me this error:
但下面的行返回给我这个错误:
Uncaught TypeError: object is not a function
未捕获的类型错误:对象不是函数
var oFCKeditor1 = new CKEDITOR('message');
Any idea ?
任何的想法 ?
回答by Ryan Weir
According to the documentation, include the ckeditor.js file:
根据文档,包含 ckeditor.js 文件:
<head>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
</head>
The editor operates on textarea
elements, so create one in your body somewhere:
编辑器对textarea
元素进行操作,因此在您的身体某处创建一个:
<textarea id="editor1" name="editor1"><p>Initial value.</p></textarea>
Then initialize the editor with the following code afterthe declaration of your textarea
element:
然后在声明元素后使用以下代码初始化编辑器textarea
:
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
回答by dodiya vijay
I was written one article for it on this link. maybe it helps Include the js file in your web page. you can also use CKEditor CDN
我在这个链接上为它写了一篇文章。也许它有助于在您的网页中包含 js 文件。您也可以使用 CKEditor CDN
<script src="https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script>
OR
<script src="CKEditor_file_path/ckeditor.js"/>
After select textarea where you want to add CKEditor
<textarea name="editor1" id="editor1" rows="10" cols="80">
This Textarea Replaced By CKEditor.
</textarea>
Write code to replace textarea in CKEditor
编写代码替换CKEditor中的textarea
<script>
CKEDITOR.replace( 'editor1' );
</script>
"editor1" is the name of textarea for more information you can view this blog
“editor1”是textarea的名称有关更多信息您可以查看此博客
http://besticoder.com/how-to-use-ckeditor-in-your-website-for-user-input/
http://besticoder.com/how-to-use-ckeditor-in-your-website-for-user-input/