百度文本编辑器

本文介绍如何下载并使用百度UEditor富文本编辑器。通过引入必要的js文件,用户可以轻松地在其项目中集成UEditor。文章提供了一个完整的示例,包括设置编辑器、获取和设置编辑器内容的方法。

百度文本编辑器的下载版本:需要引入ueditor.config.js和ueditor.all.min.js和lang/zh-cn/zh-cn.js

使用时将下载好的ueditor文件包放到www文件的目录下,并根据自己的需要选择以下的按钮

以下是html代码部分:

 View Code

新建与ueditor同级的文件testueditor.php:进行自己的操作

复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
    <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.all.min.js"> </script>
    <!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/lang/zh-cn/zh-cn.js"></script>

</head>

<body>
<div>
    <h1>完整demo</h1>
    <script id="editor" type="text/plain" style="width:800px;height:300px;"></script>
</div>
<div>
    <button onclick="getContent()">获得内容</button>
    <button onclick="setContent()">写入内容</button>
</div>
<div id="xianshi"></div>
</body>
<script type="text/javascript">
    var ue = UE.getEditor('editor');
    function getContent() {
       
      document.getElementById("xianshi").innerHTML = UE.getEditor('editor').getContent();
       
    }
    function setContent(isAppendTo) {
          
        var str = "<p>我看看是不是能行的,就是这么好会说话</p><p><img src='/ueditor/php/upload/image/20160625/1466820882121569.png' title='1466820882121569.png' alt='logo.png'></p>";
        
        UE.getEditor('editor').setContent(str, isAppendTo);
           
    }
</script>
</html> 

转载于:https://www.cnblogs.com/dianfu123/p/5622730.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值