I am using an fckeditor to provide my customers with a richer user experience.
In my zul page, i have an fckeditor and a textbox. When user select a word or a sentence in the editor i want to write the selected word in the textbox below.
Everything works perfectly in Firefox. But I have a problem getting the selected item in Internet Explorer!
I know both browser handle javascript differently. But how can I produce the same effect in IE??
My code looks like this:
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window id="window">
<script type="text/javascript">
<![CDATA[function getContent (fck, comp) {
var editor = FCKeditorAPI.GetInstance(fck.id + "!ed");
//var oDOM = editor.EditorDocument ;
//var iText ;
var selection = "";
if(document.all) {
selection = editor.EditorDocument.selection.createRange().text;
} else {
selection = editor.EditorWindow.getSelection(); // after this, won't be a string
selection = "" + selection; // now a string again
}
comp.value = selection;
}
]]>
</script>
<fckeditor id="mEditor" />
<button label="Get Content" width="100px" height="50px" id="btn" action="onclick:getContent(#{mEditor})" />
<label id="label" value="selection"/>
</window>
</zk>
Any Help or Hint will be wellcomed. Thanks!
-nat
Tue, 04/07/2009 - 14:32
#1