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
  • 相关阅读:
    HTML中的文本标签
    Java 数组的创建
    JavaScript实现LUHN算法验证银行卡号有效性
    JavaScript实现HTML页面集成QQ空间分享功能
    JavaScript中的三种弹出框的区别与使用
    Maven 项目中的 pom.xml 文件内容说明
    FTPClient 中 FTPClient.changeWorkingDirectory(filePath) 代码一直返回 false
    Eclipse 中 Debug 时鼠标悬停无法查看变量值
    Innodb ,MyISAM
    tomcat jetty
  • 原文地址:https://www.cnblogs.com/sihuiming/p/5496371.html
Copyright © 2011-2022 走看看