Hi all
I have a small script for reading selected content from the fckeditor. Everything worked out fine in Firefox 3. But when I tried to run the same code on Internet Explorer, I received an empty content.
I am new to javascript and have no clue what's wrong there. Please if anybody could provide me with a little help...
Here is my code:
<script type="text/javascript">
<![CDATA[function getContent (fck, comp) {
var editor = FCKeditorAPI.GetInstance(fck.id + "!ed");
var selection = (editor.EditorWindow.getSelection ? editor.EditorWindow.getSelection() : editor.EditorDocument.selection);
var range = (document.all ? selection.createRange() : selection.getRangeAt(selection.rangeCount - 1).cloneRange());
var iText ;
if(document.all) {
iText = editor.Selection.GetSelection().createRange().text;
alert("" + iText);
} else {
iText = editor.Selection.GetSelection();
//iText = editor.EditorWindow.getSelection(); // after this, won't be a string
iText = "" + selection; // now a string again
}
alert(iText);
comp.value = iText;
}
]]>
</script>
<div sclass="correct">
<label value="1 Konservierungsmittel für pharmazeutische Präparate; Magnetische Fluide für industrielle Zwecke." />
</div>
<fckeditor id="mEditor" />
<button label="Get Content" width="100px" height="50px" id="btn" action="onclick:getContent(#{mEditor}, #{bb})" />
<textbox id="bb" value="IT" width="250px"/>
I can get the content from Firefox but there is no way to produce the same thing in Internet Explorer.
Any Help will be wellcomed. Thank!
-nat
I have a small script for reading selected content from the fckeditor. Everything worked out fine in Firefox 3. But when I tried to run the same code on Internet Explorer, I received an empty content.
I am new to javascript and have no clue what's wrong there. Please if anybody could provide me with a little help...
Here is my code:
<script type="text/javascript">
<![CDATA[function getContent (fck, comp) {
var editor = FCKeditorAPI.GetInstance(fck.id + "!ed");
var selection = (editor.EditorWindow.getSelection ? editor.EditorWindow.getSelection() : editor.EditorDocument.selection);
var range = (document.all ? selection.createRange() : selection.getRangeAt(selection.rangeCount - 1).cloneRange());
var iText ;
if(document.all) {
iText = editor.Selection.GetSelection().createRange().text;
alert("" + iText);
} else {
iText = editor.Selection.GetSelection();
//iText = editor.EditorWindow.getSelection(); // after this, won't be a string
iText = "" + selection; // now a string again
}
alert(iText);
comp.value = iText;
}
]]>
</script>
<div sclass="correct">
<label value="1 Konservierungsmittel für pharmazeutische Präparate; Magnetische Fluide für industrielle Zwecke." />
</div>
<fckeditor id="mEditor" />
<button label="Get Content" width="100px" height="50px" id="btn" action="onclick:getContent(#{mEditor}, #{bb})" />
<textbox id="bb" value="IT" width="250px"/>
I can get the content from Firefox but there is no way to produce the same thing in Internet Explorer.
Any Help will be wellcomed. Thank!
-nat