zoukankan      html  css  js  c++  java
  • example_UEditor富文本编辑器

    <!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" />
    <script src="../Public/plugins/ueditor/ueditor.config.js"></script> <!-- 配置文件 -->
    <script src="../Public/plugins/ueditor/ueditor.all.min.js"></script> <!-- 编辑器源码文件 -->
    <title>ueditor demo</title>
    </head>
    
    <body>
    <!-- 加载编辑器的容器 -->
    <script id="editor" name="content" type="text/plain" style="800px;height:300px;">
    
        这里写你的初始化内容
        
    </script>
    <div id="btn">
        
          <button onclick="getAllHtml()">获得整个html的内容</button>
          <button onclick="getContent()">获得内容</button>
          <button onclick="setContent()">写入内容</button>
          <button onclick="setContent(true)">追加内容</button>
          <button onclick="getContentTxt()">获得纯文本</button>
          <button onclick="getPlainTxt()">获得带格式的纯文本</button>
          <button onclick="hasContent()">判断是否有内容</button>
    
    </div>
    
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
    
        var ue = UE.getEditor('editor');
        
         function getAllHtml() {
            alert(UE.getEditor('editor').getAllHtml())
        }
        
    -->    
            function getContent() {
            var arr = [];
            arr.push(UE.getEditor('editor').getContent());
            alert(arr.join("
    "));
        }
        
         function setContent(isAppendTo) {
            var arr = [];
            UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
            alert(arr.join("
    "));
        }
        
        function getContentTxt() {
            var arr = [];
            arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
            arr.push("编辑器的纯文本内容为:");
            arr.push(UE.getEditor('editor').getContentTxt());
            alert(arr.join("
    "));
        }
        
         function getPlainTxt() {
            var arr = [];
            arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
            arr.push("内容为:");
            arr.push(UE.getEditor('editor').getPlainTxt());
            alert(arr.join('
    '))
        }
        
         function hasContent() {
            var arr = [];
            arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
            arr.push("判断结果为:");
            arr.push(UE.getEditor('editor').hasContents());
            alert(arr.join("
    "));
        }
    
        
    </script>
    </body>
    
    </html>
    View Code
  • 相关阅读:
    [vijos P1531] 食物链
    [USACO精选] 第二章 动态规划(一)
    python 二分法查找
    python 小试牛刀之信息管理
    C语言链表实现冒泡法排序
    [笔记]libgdx在一张pixmap上按照笔刷画图
    [libgdx]项目通过RoboVm编译到ios平台并运行的环境配置
    android中sqlite distinct中使用多个字段的方法
    libgdx游戏中的中文字体工具类
    C语言实现字符串拷贝 拷贝指定长度字符串 字符串连接
  • 原文地址:https://www.cnblogs.com/sihuiming/p/5496371.html
Copyright © 2011-2022 走看看