如何在页面中运行多个FCKeditor控件
时间: 2023-11-22 21:04:56 浏览: 86
要在页面中运行多个FCKeditor控件,需要为每个控件创建一个唯一的ID,并在页面中引入FCKeditor的脚本文件。然后在JavaScript中初始化每个控件,并将其关联到其对应的ID。以下是示例代码:
HTML代码:
```
<textarea id="editor1"></textarea>
<textarea id="editor2"></textarea>
```
JavaScript代码:
```
// 引入FCKeditor脚本文件
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
// 初始化第一个控件
var editor1 = new FCKeditor('editor1');
editor1.BasePath = '/fckeditor/';
editor1.ReplaceTextarea();
// 初始化第二个控件
var editor2 = new FCKeditor('editor2');
editor2.BasePath = '/fckeditor/';
editor2.ReplaceTextarea();
```
在这个示例中,我们使用了两个textarea元素来创建两个编辑器控件,分别使用了ID为"editor1"和"editor2"。在JavaScript代码中,我们使用了FCKeditor的API来初始化每个控件,并将其关联到其对应的ID。注意要为每个控件设置不同的BasePath,以确保它们可以正确加载所需的资源。
相关问题
如何在页面中运行多个FCKeditor控件,如何加入数据库中
要在页面中运行多个 FCKeditor 控件,可以使用 JavaScript 动态创建多个 textarea 元素,并分别实例化为 FCKeditor 控件。例如:
```html
<div id="editor1"></div>
<div id="editor2"></div>
<button onclick="save()">保存</button>
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
var editor1 = new FCKeditor('editor1');
editor1.BasePath = '/fckeditor/';
editor1.Height = 300;
editor1.Create();
var editor2 = new FCKeditor('editor2');
editor2.BasePath = '/fckeditor/';
editor2.Height = 300;
editor2.Create();
function save() {
var content1 = editor1.GetXHTML();
var content2 = editor2.GetXHTML();
// 将 content1 和 content2 插入数据库中
}
</script>
```
在保存按钮的点击事件中,获取每个编辑器的内容,并将其插入到数据库中即可。
注意:FCKeditor 已经停止更新,推荐使用其后继者 CKEditor。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)