简体   繁体   English

如何在客户端获取 Html 数据 ckEditor?在客户端通过更改字符预览结果?

[英]how get the Html data ckEditor on client?preview result by change character on client?

I am having problem to get data html written in ckeditor in Jquery.我在 Jquery 中获取用 ckeditor 编写的数据 html 时遇到问题。
I can't select data by jQuery because this editor loading file after $(document).ready()我无法通过 jQuery 选择数据,因为此编辑器在 $(document).ready() 之后加载文件
I get data and post by $.ajax{} to db , and show in preview section.我获取数据并通过 $.ajax{} 发布到 db ,并在预览部分显示。
(c# / asp.net) (c#/asp.net)

my problem:我的问题:
I can't get elementID.我无法获取 elementID。
i use the ckeditor by add dll to toolbox.我通过将 dll 添加到工具箱来使用 ckeditor。

ckeditor in html code html代码中的ckeditor

<CKEditor:CKEditorControl ID="CKEditorControl" runat="server"  
            BasePath="ckeditor" ContentsCss="ckeditor/contents.css" 
            Height="250px" 
            TemplatesFiles="ckeditor/themes/default/theme.js" FilebrowserBrowseUrl="ckeditor/plugins/FileManager/index.html" 
            FilebrowserFlashBrowseUrl="ckeditor/plugins/FileManager/index.html" FilebrowserFlashUploadUrl="ckeditor/plugins/FileManager/index.html" 
            FilebrowserImageBrowseLinkUrl="ckeditor/plugins/FileManager/index.html" FilebrowserImageBrowseUrl="ckeditor/plugins/FileManager/index.html" 
            FilebrowserImageUploadUrl="ckeditor/plugins/FileManager/index.html" 
            FilebrowserUploadUrl="ckeditor/plugins/FileManager/index.html" BackColor="#FF0066" 
                    DialogButtonsOrder="Rtl" 
                    FontNames="B Yekan; B Yekan,tahoma;Arial/Arial, Helvetica, sans-serif; Comic Sans MS/Comic Sans MS, cursive; Courier New/Courier New, Courier, monospace; Georgia/Georgia, serif; Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif; Tahoma/Tahoma, Geneva, sans-serif; Times New Roman/Times New Roman, Times, serif; Trebuchet MS/Trebuchet MS, Helvetica, sans-serif; Verdana/Verdana, Geneva, sans-serif" 
                    ResizeDir="Vertical" ResizeMinHeight="350" UIColor="#CACACA">dhd fdh</CKEditor:CKEditorControl>

can any one help me out?谁能帮我吗?

=========================== ============================
method in core.ckeditor.js core.ckeditor.js 中的方法

getData : function()
        {
            this.fire( 'beforeGetData' );
 
            var eventData = this._.data;

            if ( typeof eventData != 'string' )
            {
                var element = this.element;
                if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
                    eventData = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
                else
                    eventData = '';
            }

            eventData = { dataValue : eventData };
 
            // Fire "getData" so data manipulation may happen.
            this.fire( 'getData', eventData );
 
            return eventData.dataValue;
        }

description:描述:

{String} getData() Since: 3.0
Gets the editor data. The data will be in raw format. It is the same data that is posted by the editor. 
Defined in: core/editor.js.
if ( CKEDITOR.instances.editor1.getData() == '' )
    alert( 'There is no data available' );
Returns:
{Undefined} (String) The editor data.

i writed code:我写的代码:
html: html:

<textarea id="editor"></textarea>

js: js:

var edit = CKEDITOR.replace('editor');
        alert(CKEDITOR.instances.edit.getData());

But not happend?但没有发生?

method in core.ckeditor.js core.ckeditor.js中的方法

getData : function()
        {
            this.fire( 'beforeGetData' );

            var eventData = this._.data;

            if ( typeof eventData != 'string' )
            {
                var element = this.element;
                if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
                    eventData = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
                else
                    eventData = '';
            }

            eventData = { dataValue : eventData };

            // Fire "getData" so data manipulation may happen.
            this.fire( 'getData', eventData );

            return eventData.dataValue;
        }

description: 描述:

{String} getData() Since: 3.0
Gets the editor data. The data will be in raw format. It is the same data that is posted by the editor. 
Defined in: core/editor.js.
if ( CKEDITOR.instances.editor1.getData() == '' )
    alert( 'There is no data available' );
Returns:
{Undefined} (String) The editor data.

i writed code: 我写的代码:
html: 的HTML:

<textarea id="editor"></textarea>

js: js:

var edit = CKEDITOR.replace('editor');
        alert(CKEDITOR.instances.edit.getData());

but not happend? 但没有发生?

Use

alert(CKEDITOR.instances.<%=CKEditorControl.ClientID %>.getData());

It works.有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何防止HTML中的客户端更改数据属性? - how to prevent client-side change data-attributes in HTML? 如何获取变量中返回的Google Place Autocomplete API结果,而不是将结果通过HTML输入元素提供给客户端 - How to get result of google place Autocomplete API returned in a variable instead of serving result in HTML input element to the client Lightswitch HTML Client Preview2中的字段格式 - Field Formatting in Lightswitch HTML Client Preview2 如何将表单数据传递到客户端函数(google.scripts.run)并将结果返回到HTML? - How to pass a form data to a client side function (google.scripts.run) and return result to HTML? 从服务器获取图像并在客户端上预览 - Get image from server and preview it on client 如何在客户端或javascript中获取页面HTML - how to get page HTML at client side or javascript 如何在CKEDITOR中从html字符串显示html预览? - How to show html preview from html String in CKEDITOR? 如何在客户端更改XML属性,然后在服务器端保存结果? - How to change XML attribute on the client side and then save the result on the server side? 如何在 CKeditor 5 中打印预览? - How to print preview in CKeditor 5? 如何获取ckeditor的内容? - How to get the contents of ckeditor on change?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM