簡體   English   中英

CKEDITOR獲取實例不起作用

[英]CKEDITOR get instance doesnt working

我有一個ckeditor對象,我想插入文本當前位置。 所以我嘗試獲取ckeditor對象,但頁面返回錯誤。 我的ckeditor版本是3.6.4

ASPX:

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

    <CKEditor:CKEditorControl Width="100%" BasePath="~/Controls/Base/ckeditor" CssClass="AutoCompColumnList" ID="txtMessageBody" Height="500px" runat="server"
    </CKEditor:CKEditorControl>

    </ContentTemplate>
 </asp:UpdatePanel>

我嘗試了這個:

CKEDITOR.instances.txtMessageBody.insertText('這里有一些文字');

錯誤:

CKEDITOR未定義!

我最近嘗試使用CKEditor,但放棄了,因為它似乎花了很長時間才能進入頁面,並且因為它一直在html旁邊添加回車符。 為了擺脫這一點,我不得不寫這個:

var editor;
function changeEnter()
{
if (editor)
    editor.destroy(true);

editor = CKEDITOR.replace('CKEditor1',
{
on:
{
instanceReady: function (ev)
{
//output paragraphs as <p>Text</p>
this.dataProcessor.write.setRules('p',
{
indent: false,
breakBeforeOpen: true
});
}
}
});
window.onload = changeEnter;

我從他們的示例頁面之一中提取了所有內容。 我真的不知道它是做什么的,但是它可以工作。 在將其放置在頁面上之前,我一直在獲取CKEditor未定義消息。

抱歉,不能麻煩縮進代碼。 為什么在此網站上發布代碼如此困難。 它將自己設置為卓越的軟件論壇-但是您編寫代碼的方式卻很糟糕。 為什么沒有像您這樣的[code]標簽在其他網站上獲得?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM