zoukankan      html  css  js  c++  java
  • FCK 相关函数


    文本框改变事件.开始
    <textarea cols="1" rows="1" id="txt2" name="txt2" style=" 400px; height: 60px;"  ></textarea>
           
            <script type="text/javascript" language="javascript">
                var scpMgr = new CaptureManager();
                //http://www.ncmem.com/products/screencapture/demo/upload.aspx,如果不是这个域名。可能出现域名未授权现象
                //scpMgr.Config["PostUrl"] = "http://192.168.0.100/market/asp.net/upload.aspx";
                scpMgr.Config["PostUrl"] = "http://www.ncmem.com/products/screencapture/demo/upload.aspx";

                var oFCKeditor = new FCKeditor('txt2');

                oFCKeditor.BasePath = "fckeditor/";
                oFCKeditor.ToolbarSet = 'Basic';
                oFCKeditor.Width = "400";
                oFCKeditor.Height = "200";
                oFCKeditor.ReplaceTextarea();
               
                function FCKeditor_OnComplete(editorInstance) {
                    scpMgr.Init(editorInstance); //初始化
                    editorInstance.EditorDocument.attachEvent("onkeydown", editor_keydown);
                }
                function editor_keydown() {

                    var oEditor = FCKeditorAPI.GetInstance("txt2");
                    var str1 = oEditor.GetXHTML(true);
                    alert(str1);
    //                if (str1.indexof('src="/upload') > 0) {
    //                    str1 = str1.replace('src="/upload', "http://www.ncmem.com/upload");
    //                }
    //                oEditor.SetHTML(str1, false);
                }
        </script>
    文本框改变事件.结束



    获取FCK的实例
    FCKeditorAPI是FCKeditor加载后注册的一个全局对象,利用它我们就可以完成对编辑器的各种操作。
    在当前页获得 FCK 编辑器实例:
    var Editor = FCKeditorAPI.GetInstance('InstanceName');
    从 FCK 编辑器的弹出窗口中获得 FCK 编辑器实例:
    var Editor = window.parent.InnerDialogLoaded().FCK;
    从 框架页面的子框架中获得其它子框架的 FCK 编辑器实例:
    var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');
    从页面弹出 窗口中获得父窗口的 FCK 编辑器实例:
    var Editor = opener.FCKeditorAPI.GetInstance('InstanceName');
    FCK获取焦点
    获 取焦点是否在FCK中:
    oEditor.HasFocus
    FCK获取焦点:
    oEditor.Focus();// 获取焦点
    获取和设置FCK的内容
    获得 FCK 编辑器的内容:
    oEditor.GetXHTML(formatted); // formatted 为:true|false,表示是否按HTML格式取出。
    设置 FCK 编辑器的内容:
    oEditor.SetHTML("content", false); // 第二个参数为:true|false,是否以所见即所得方式设置其内容。
    插入内容到 FCK 编辑器:
    oEditor.InsertHtml("html"); // "html"为HTML文本
    检查 FCK 编辑器内容是否发生变化:
    oEditor.IsDirty();
    1 // 获取编辑器中HTML内容
    2 function getEditorHTMLContents(EditorName) {
    3 var oEditor = FCKeditorAPI.GetInstance(EditorName);
    4 return(oEditor.GetXHTML(true));
    5 }
    6
    7 // 获取编辑器中文字内容
    8 function getEditorTextContents(EditorName) {
    9 var oEditor = FCKeditorAPI.GetInstance(EditorName);
    10 return(oEditor.EditorDocument.body.innerText);
    11 }
    12
    13 // 设置编辑器中内容
    14 function SetEditorContents(EditorName, ContentStr) {
    15 var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
    16 oEditor.SetHTML(ContentStr) ;
    17 }
    18

    FCK的事件处理

    FCK 定义有OnComplete,OnBlur和OnFocus等事件,这样就可以使用事件的处理函数完成相应的处理。

    FCK添加事件处理 函数的方法是:fckInstance.Events.AttachEvent( EventName, function)

    代码
    //FCKeditor 加载完成后做处理的方法
    function FCKeditor_OnComplete( editorInstance )
    {
    editorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;
    editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
    }

    function FCKeditor_OnBlur( editorInstance )
    {
    //失去焦点收起工具栏
    editorInstance.ToolbarSet.Collapse() ;
    }

    function FCKeditor_OnFocus( editorInstance )
    {

    editorInstance.ToolbarSet.Expand() ;
    }
  • 相关阅读:
    tcpip详解笔记(1) 概述
    tcpip详解笔记(11) 广播和多播
    tcpip详解笔记(13) tftp
    tcpip详解笔记(15) TCP协议连接过程
    tcpip详解笔记(8) traceroute
    tcpip详解笔记(5) RARP协议
    tcpip详解笔记(6) icmp协议
    tcpip详解笔记(7) ping
    tcpip详解笔记(4) arp协议
    tcpip详解笔记(3) IP网际协议
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783818.html
Copyright © 2011-2022 走看看