How can i move cursor position. I want to replace text in the field, but whenever i do SetHTML the cursor goes to the beginning of the editor. Anyone to do this so the cursor goes back to where it was? thanks.
Mon, 10/30/2006 - 19:01
#1

RE: cursor position
RE: cursor position
Question though, what is the node.
FCKeditorAPI.GetInstance("FCKeditor").Selection.MoveToAncestorNode(nodeTagName);
nodeTagName, what would that be. Maybe i could set a node at the end or something and move the cursor to it.
unless there is another way to do this. Basically i want to change text on the fly, so your typing and when you type something it will check it and then change and i want to continue to type without any flaws. Trying to figure out how i can do this though.
RE: cursor position
RE: cursor position
What does that do? I have a button in fckeditor and it just does the function from there instead of opening a new page. Is there a way to get the parentnode? That way i can just use the replaceall function.
RE: cursor position
RE: cursor position
RE: cursor position
Basically use like lastchild or something and select the lastchild and then move the cursor there.
I tried some thing but cant get it to work.
I did window.FCK.EditorDocument.body.lastChild. This works ok. But now how do i select it? I tried a bunch of different things and cant seem to get it.
var oLastChild = FCK.EditorDocument.body.lastChild;
????.Selection.SelectNode(oLastChild);
Not sure what goes in the ????. Little confused on that part.
RE: cursor position
RE: cursor position
I want to replace text in the field, but whenever i do SetHTML the cursor goes to the beginning of the editor. Anyone to do this so the cursor goes back to where it was?
I too face the same problem. can anyone have this solution.
Thanks
Cursor position After Insert Text
I want to insert text in fckeditor when i click the button, but whenever i do SetHTML the cursor goes to the beginning of the editor. Anyone to do this so the cursor goes back to where it was?
I too face the same problem. can anyone have this solution.
Thanks
RE: cursor position
<script language=javascript>
function InsertHTML(FCKEditorName,TextToInsert)
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(FCKEditorName) ;
// Check the active editing mode.
if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
{
// Insert the desired HTML.
oEditor.InsertHtml( TextToInsert ) ;
}
else
alert( 'You must be on WYSIWYG mode!' ) ;
}
</script>
<INPUT TYPE="button" VALUE="Add" ONCLICK="InsertHTML('Para',this.form.aText.value);" id=button2 name=button2>
Where Para is the name of the FCKeditor and aText contains the text you want to insert.
Hope it works...
Lina
RE: cursor position
However on IE (6&7) text is inserted at the beginning of the editor accessible or apparent area. Usually that is the beggining of the text, but when there are hidden areas (using positioning or display attributes) the insert is done at the top visible location and not where the cursor is.
Could't find a workaround, so far...