How can I get the text which is currently selected in the Editor Window?
I was using this version: FCK.EditorWindow.getSelection(), but this only works in Firefox. What is the way to get the selected text for Internet Explorer or is there a crossbrowser way to do this?
I was using this version: FCK.EditorWindow.getSelection(), but this only works in Firefox. What is the way to get the selected text for Internet Explorer or is there a crossbrowser way to do this?

RE: How to get the selected text?
RE: How to get the selected text?
To made this possible I have created the following code:
--- [ CODE ] ---------------------------
var sSelected;
if ( oEditor.FCKBrowserInfo.IsGecko ) {
sSelected = FCK.EditorWindow.getSelection();
} else {
sSelected = FCK.EditorDocument.selection.createRange().text;
}
--- [ CODE ] ---------------------------
Can someone tell me if this is the correct way for doing this!? As for the Gecko part I use 'EditorWindow' and for the IE part is use the 'EditorDocument' object.
RE: How to get the selected text?
RE: How to get the selected text?
-- [ CODE ] ------
var txt = document.selection.createRange().text;
-- [ CODE ] ------
and for Gecko you can work with the following code:
-- [ CODE ] ------
var txt = window.getSelection();
-- [ CODE ] ------
The only thing is that I can't test this function with IE on MAC, but I assume most people use Safari.
RE: How to get the selected text?
I could not get FCK.Selection to work, but this does. Please feel free to incorporate this back into FCK as part of the base API, as I think it's very useful for plugin devs.
// Useful generic function for determining if something is selected in the editor. Tested IE and FF.
function editorHasSelection()
{
var FCK = window.parent.InnerDialogLoaded().FCK ;
var bHasSelection = false;
try {
var oSel = null;
if(document.all) {
oSel = FCK.EditorDocument.selection ; // ie
bHasSelection = !(oSel.type == "None");
} else {
oSel = FCK.EditorWindow.getSelection() ; // gecko
bHasSelection = (oSel && oSel.rangeCount == 1 && oSel.getRangeAt(0).cloneContents().childNodes.length > 0);
}
} catch (e) {}
return bHasSelection;
}
RE: How to get the selected text?
https://sourceforge.net/forum/forum.php ... _id=257180
RE: How to get the selected text?
Could you pls tell me what could be the reason