zoukankan      html  css  js  c++  java
  • 用CKEDITOR 做自助上传的解决方案2

    1,在plugins下新建文件夹 multiimg

    2,创建文件plugin.js

    (function() {
        CKEDITOR.plugins.add("multiimg", {
            requires: ["dialog"],
            init: function(a) {
                a.addCommand("multiimg", new CKEDITOR.dialogCommand("multiimg"));
                a.ui.addButton("multiimg", {
                    label: "批量上传图片",//调用dialog时显示的名称
                    command: "multiimg",
                    icon: this.path + "g.ico"//在toolbar中的图标
    
                });
                CKEDITOR.dialog.add("multiimg", this.path + "dialogs/multiimg.js")
    
            }
    
        })
    
    })();
    

      3,创建一个g.ico  放在multiimg目录下

    4,创建dialogs文件夹,创建文件multiimg

    (function() {
        CKEDITOR.dialog.add("multiimg",
            function(a) {
                return {
                    title: "批量上传图片",
                    minWidth: "660px",
                    minHeight:"400px",
                    contents: [{
                        id: "tab1",
                        label: "",
                        title: "",
                        expand: true,
                         "420px",
                        height: "300px",
                        padding: 0,
                        elements: [{
                            type: "html",
                            style: "660px;height:400px",
                            html: '<iframe id="uploadFrame" src="/image/image.html?v=' +new Date().getSeconds() + '" frameborder="0"></iframe>'
                        }]
                    }],
                    onOk: function() {
                        // 拿到對象,這個在iframe里定義
                        var num = window.fff;
    
                        //点击确定按钮后的操作
                        a.insertHtml("编辑器追加内容"+num);
                    },
                    onShow: function () {
                        document.getElementById("uploadFrame").setAttribute("src","/image/image.html?v=' +new Date().getSeconds() + '");
                    }
                }
            })
    })();
    

      

    5,做那个上传页面,

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     2         "http://www.w3.org/TR/html4/loose.dtd">
     3 <html>
     4 <head>
     5     <title></title>
     6 
     7     <script type="text/javascript" src="/res/js/jquery-1.12.1.js"></script>
     8 
     9 
    10 </head>
    11 <body>
    12 
    13 <img id="imgs">fuck</img>
    14 
    15 
    16 <script type="text/javascript">
    17     parent.fff =("fsdafsdafsdafsda");
        //关键,可以在...被调用
    18 19 var a =$(window.parent.document).find("#title").val("================"); 20 21 </script> 22 </body> 23 24 </html>

     config.extraPlugins += 'multiimg';

    自定义按钮

    config.toolbar = [
    ['Source', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo', 'Bold', 'Italic',
    "Format","FontSize","TextColor" ,"Link" ,"Unlink","CodeSnippet"]
    ]

  • 相关阅读:
    使用JQuery从客户端调用C#方法
    上传文件插件 Uploadify使用说明 转
    juqery 操作select
    XP下安装IIS6.0的办法 转
    更改2003远程桌面端口3389为其他端口号
    Web打印
    远程桌面 客户端无法建立跟远程计算机的连接 解决办法
    WPF的“.NET研究”消息机制(一) 让应用程序动起来 狼人:
    应用Visual Studio 2010辅“.NET研究”助敏捷测试(上) 狼人:
    ASP.NET调用.sql文件(二“.NET研究”) 狼人:
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5935349.html
Copyright © 2011-2022 走看看