Hi I am trying to insert a string at the cursor position in the editor.
According to some post that i read in this forum "InsertHtml" is suppose to do just that. But when i use InsertHtml my string gets inserted / appended to the beginning of the editors string. Am i maybe missing something?
Does anybody have any solution for me.
Thanks Wayne
According to some post that i read in this forum "InsertHtml" is suppose to do just that. But when i use InsertHtml my string gets inserted / appended to the beginning of the editors string. Am i maybe missing something?
Does anybody have any solution for me.
Thanks Wayne
RE: FckEditor.InsertHtml() not working
function insertTextAtCaret(text)
{
var Hid = document.all['W_449:USR_HTMLEditor1:USR_TextConstantPicker1:hidHTMLEditorName'];
var editor = FCKeditorAPI.GetInstance(Hid.value + ":FCKeditor1");
editor.InsertHtml(text);
}
RE: FckEditor.InsertHtml() not working
RE: FckEditor.InsertHtml() not working
Write your own InsertHTML-function like this:
function InsertHTML()
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
// Check the active editing mode.
if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
{
// Insert the desired HTML.
oEditor.InsertHtml( '- This is some <b>sample</b> HTML -' ) ;
}
else
alert( 'You must be on WYSIWYG mode!' ) ;
}
Change "FCKeditor1" to the name of your instance. And all is well!
RE: FckEditor.InsertHtml() not working
Thanks, i found my problem: I was using a contextmenu control from the PeterBlum controls for .NET and this was causing this funny behaviour.

The context menus display constant values that i would like to insert into the Fckeditor - but what happened is that every time the context menu appeared the editor was losing focus and the javascript was inserting the text to the begning of the editor - because that is where the cursor was after receiving focus again.
So i had to drop the context menu
RE: FckEditor.InsertHtml() not working