CKEditor/FCKEditor 使用 CKeditor 3.0.1 快速使用教程(含插入图片)
时间:2022-10-16 14:04:14
因为直接把内容作为字符串给编辑器的 Value 属性赋值使用的是 JavaScript 代码,要让 JS 代码不受内容中双引号、换行等的干扰,只有先读入到 textarea 最方便。
使用 CKeditor 3.0.1
<textarea cols="90" rows="10" id="content" name="content">cftea</textarea>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
<!--
CKEDITOR.replace("content");
//-->
</script>
可以看出,3.x 版本的使用非常方便,也不用担心会形成两个同名的 content。实际上 textarea 的 id 省略了也是可以的,因为 CKEditor 会先按 name 来查找,查找不到,再按 id 来查找。
并且编辑器会在 textarea 的位置替换原有的 textarea。
设置编辑器皮肤、宽高
<textarea cols="90" rows="10" id="content" name="content">cftea</textarea>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
<!--
CKEDITOR.replace("content",
{
skin: "kama", width:700, height:300
});
//-->
</script>
skin 值应该是 ckeditor/skins 文件夹下的某个文件夹名称,如果指向不存在的皮肤,则不会显示编辑器。
设置值、取值
设置值
CKEDITOR.instances.content.setData("脚本之家"); // content 就是前面 CKEDITOR.replace 的第一个参数值
或
var editor = CKEDITOR.replace("content");
editor.setData("脚本之家");
取值
alert(CKEDITOR.instances.content.getData()); // content 就是前面 CKEDITOR.replace 的第一个参数值
或
var editor = CKEDITOR.replace("content");
alert(editor.getData());
插入图片
若要演示此示例,最好是放在按钮的事件处理程序中,目的是有些延迟。
CKEDITOR.instances.content.insertHtml("<img src=...>");
标签:CKeditor,网页编辑器,使用教程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
php比较两个指定的日期的实例讲解
2023-06-13 12:11:29
Maven中央仓库正式成为Oracle官方JDBC驱动程序组件分发中心(推荐)
2024-01-26 05:26:27
![](https://img.aspxhome.com/file/2023/7/86037_0s.png)
Python如何获取多线程返回结果
2024-01-01 23:34:28
FrontPage 2002应用技巧四则
2008-08-17 10:57:00
javascript 三 级下拉选择菜单Levels对象
2023-09-05 03:28:48
重新发现HTML表格
2009-12-02 09:47:00
![](https://img.aspxhome.com/file/UploadPic/200912/2/01-38s.png)
利用python调用摄像头的实例分析
2022-01-03 22:10:14
Python使用filetype精确判断文件类型
2023-07-09 12:30:12
零基础写python爬虫之抓取糗事百科代码分享
2021-02-01 11:54:39
![](https://img.aspxhome.com/file/2023/6/134436_0s.png)
轻松解决AJAX的中文乱码问题
2008-09-03 12:55:00
PWA介绍及快速上手搭建一个PWA应用的方法
2024-04-19 09:56:33
![](https://img.aspxhome.com/file/2023/1/136001_0s.jpg)
MySQL left join操作中on和where放置条件的区别介绍
2024-01-19 14:10:06
Eclipse + Python 的安装与配置流程
2021-07-25 06:34:18
用ASP实现在线压缩与解压缩
2007-09-29 12:13:00
浅谈Python小波分析库Pywavelets的一点使用心得
2023-03-11 22:55:23
![](https://img.aspxhome.com/file/2023/7/75207_0s.png)
GoLang中的互斥锁Mutex和读写锁RWMutex使用教程
2024-05-25 15:13:05
python中合并两个文本文件并按照姓名首字母排序的例子
2023-05-28 17:41:32
Python设计模式之备忘录模式原理与用法详解
2022-12-27 11:12:01
![](https://img.aspxhome.com/file/2023/5/120335_0s.png)
PyTorch 可视化工具TensorBoard和Visdom
2022-04-28 00:30:41
![](https://img.aspxhome.com/file/2023/7/121017_0s.png)
asp如何做一个随机密码产生器?
2010-07-12 18:57:00