简体   繁体   English

CKEDITOR获取实例不起作用

[英]CKEDITOR get instance doesnt working

I have a ckeditor object and i want to insert text current position. 我有一个ckeditor对象,我想插入文本当前位置。 So i try to get ckeditor object but page returns error. 所以我尝试获取ckeditor对象,但页面返回错误。 My ckeditor version is 3.6.4 我的ckeditor版本是3.6.4

ASPX: 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>

I tried this: 我尝试了这个:

CKEDITOR.instances.txtMessageBody.insertText('some text here'); CKEDITOR.instances.txtMessageBody.insertText('这里有一些文字');

Error: 错误:

CKEDITOR is not defined! CKEDITOR未定义!

I tried using CKEditor recently but gave up because it seemed to take a long time to get on the page and because it kept adding carriage returns in side the html. 我最近尝试使用CKEditor,但放弃了,因为它似乎花了很长时间才能进入页面,并且因为它一直在html旁边添加回车符。 To get rid of that I had to write this: 为了摆脱这一点,我不得不写这个:

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;

I took all that from one of their sample pages. 我从他们的示例页面之一中提取了所有内容。 I don't really know what it does, but it works. 我真的不知道它是做什么的,但是它可以工作。 Before putting that on the page I kept getting CKEditor is not defined messages. 在将其放置在页面上之前,我一直在获取CKEditor未定义消息。

Sorry, can't be bothered to indent the code. 抱歉,不能麻烦缩进代码。 Why is it so hard to post code on this site. 为什么在此网站上发布代码如此困难。 It sets itself up as the pre-eminent software forum - yet the way you have to write code is awful. 它将自己设置为卓越的软件论坛-但是您编写代码的方式却很糟糕。 Why no [code] tags like you get on other sites? 为什么没有像您这样的[code]标签在其他网站上获得?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM