`
zccst
  • 浏览: 3293898 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用FCKeditorAPI与fckeditor交互

 
阅读更多
使用FCKeditorAPI与fckeditor交互
作者:zccst

1,获取name值,

FCKeditorAPI.GetInstance('yourtextareaname').GetHTML();  //整个dom
FCKeditorAPI.GetInstance('yourtextareaname').GetXHTML(); //带标签

也可以
FCKeditorAPI.Instances.yourtextareaname.GetXHTML(html);

GetHTML( formatted ), or GetXHTML( formatted ), or GetData( formatted )
- retrieves the edited html from the editor.
获取编辑器中的html内容,其中oEditor.GetXHTML(formatted); // formatted 为:true|false,表示是否按HTML格式取出


2,设置name值
FCKeditorAPI.Instances.yourtextareaname.SetHTML(html);
追加插入name值
FCKeditorAPI.Instances.yourtextareaname.InsertHtml(html);


批注:其实弄清楚如何使用,最好的办法是查看dom。因为一旦fckeditor加载成功,则会显示其dom对象,及子对象,还有他们的方法。



附:官方资料
FCKeditor JavaScript API

地址:http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/JavaScript_API


FCKeditor offers a complete JavaScript API so you can interact with it once the editor is loaded and running.

Once loaded, the editor registers a global object called FCKeditorAPI. This object offers the entry point to

interact with any editor instance placed in a page (you can have more than one).

NOTE: The FCKeditorAPI object will not be available during the page load. You need to wait for the editor to

be loaded to use it. If you need to interact with the editor right after is has been loaded, use the

"FCKeditor_OnComplete" function (see Events).

Retrieving an Editor Instance

    From out of an external script
    When placing the editor in the page, you give it an "instance name". To retrieve it, you must simply call the FCKeditorAPI.GetInstance method.
    Example:

    var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;

    From out of a dialog of the editor
    Call the InnerDialogLoaded to get the FCKObject.
    Example:

    var oEditor = window.parent.InnerDialogLoaded().FCK ;

Both methods return the main FCKeditor object that gives the necessary bridge to interact with it. These are the most useful properties and methods of this object:

Properties:

    Name = ( string ) - the instance name.
    Status = ( integer ) - the editor status (loading status).
    EditorDocument = ( object ) - the DOM Document object for the editing area.
    EditorWindow = ( object ) - the DOM Window object for the editing area.

Methods:

    AttachToOnSelectionChange( functionPointer )
    Focus()
    SetHTML( html ), or SetData( html ) - sets the contents of the editor. Note that when using this method, you will loose any listener that you may have previously registered on the editor.EditorDocument.
    GetHTML( formatted ), or GetXHTML( formatted ), or GetData( formatted ) - retrieves the edited html from the editor.
    InsertElement( element )
    InsertElementAndGetIt( e )
    InsertHtml( html ) - inserts HTML in the current cursor position
    IsDirty() - checks if the content in the editor has been changed
    MakeEditable()
    ResetIsDirty() - resets the dirty state
    SwitchEditMode()
    UpdateLinkedField()
分享到:
评论

相关推荐

    java开源包8

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    JAVA上百实例源码以及开源项目源代码

    2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...

    java开源包1

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包11

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包2

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包3

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包6

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包5

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包10

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包4

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包7

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包9

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    java开源包101

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    Java资源包01

    WebSocket4J 是一个用 Java 实现的 WebSocket 协议的类库,可使用 Java 来构建交互式 Web 应用。WebSocket4J 并未实现客户端通讯协议,所以不能用它来连接 WebSocket 服务器。 Struts验证码插件 JCaptcha4Struts2 ...

    JAVA上百实例源码以及开源项目

    2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...

Global site tag (gtag.js) - Google Analytics