Please, help me!I've searched everywhere and coludn't find any solution. I need to make text range selection in fckeditor from javascript function.
I couldn't use standard methods for textarea, like this
var previewControl = document.getElementById(id);
var range = previewControl.createTextRange();
range.moveStart("character", startIndex);
range.moveEnd("character", endIndex-newText.length);
range.select();
Maybe anybody has some solution? Thanks in advance!
Thu, 03/12/2009 - 10:03
#1
Re: How to create FCKEditor Text selection from javascript
Re: How to create FCKEditor Text selection from javascript
I was facing the same problem last week.. I need to provide a way to catch selected text in the editor but there were no documentation at all!..
With the help of a javascript partner i succeded... Here is a workaround:
<script type="text/javascript">
<![CDATA[function getContent (fck) {
var editor = FCKeditorAPI.GetInstance(fck.id + "!ed");
var oDOM = editor.EditorDocument ;
var iText ;
if (document.all)
{
iText = editor.EditorDocument.selection.createRange().text;
}
else
{
iText = editor.EditorWindow.getSelection();
}
alert(iText );
} ]]>
</script>
Hope this helps!
-nat