Asp.net mvc 2 如何在asp.net MVC2中使用javascript在光标位置插入文本

Asp.net mvc 2 如何在asp.net MVC2中使用javascript在光标位置插入文本,asp.net-mvc-2,Asp.net Mvc 2,我在asp.net中开发,屏幕上有一个CKEDITOR,光标位于应该添加一些文本的位置。 页面上存在一个按钮,当按下按钮时,将打开一个具有文本区域的modalbox,用户可以在按下按钮时光标所在的位置将文本插入其中,但不应在光标所在的位置丢失或替换文本。 是否可以在javascript中将用户输入传递给ckeditor的insertText或insertHtml函数,具体取决于您是想将其作为文本还是html源插入。它们将插入编辑器中的光标/焦点位置 因此,如果用户输入类似于: Some

我在asp.net中开发,屏幕上有一个CKEDITOR,光标位于应该添加一些文本的位置。 页面上存在一个按钮,当按下按钮时,将打开一个具有文本区域的modalbox,用户可以在按下按钮时光标所在的位置将文本插入其中,但不应在光标所在的位置丢失或替换文本。
是否可以在javascript中将用户输入传递给ckeditor的insertText或insertHtml函数,具体取决于您是想将其作为文本还是html源插入。它们将插入编辑器中的光标/焦点位置

因此,如果用户输入类似于:

    Some text and link: <a href="www.on47.com">on47</a> 
让我知道您使用的是什么版本的ckeditor,ckeditor 4的insertHtml接受第二个参数,这是可选的,默认情况下设置为html插入模式insertHtml中的第二个参数是模式,可以是文本、html、未过滤的html等

 editor.insertHtml(insertMe, 'text');
//you can get the user input from text area using javascript like below
var insertMe = document.getElementById('textAreaId').value;

//or using jquery as below
//var insertMe = $('#textAreaId').val();

//get your editor instance and insert the text or html
var editor = CKEDITOR.instances.wckEditor;

editor.insertText(insertMe); 
            OR
//editor.insertHtml(insertMe);
 editor.insertHtml(insertMe, 'text');