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
  • 相关阅读:
    iOS7上在xib中使用UITableViewController设置背景色bug
    Android 转载一篇.9图片详解文章
    Android 中4种屏幕尺寸
    网络传输中的三张表,MAC地址表、ARP缓存表以及路由表
    防火墙简介
    Makefile有三个非常有用的变量。分别是$@,$^,$
    makefile简单helloworld
    Python异常处理try except
    shell 读取配置文件的方法
    ubuntu 添加开机启动服务
  • 原文地址:https://www.cnblogs.com/sihuiming/p/5496371.html
Copyright © 2011-2022 走看看