This may be a stupid question, but how do I get the currently selected text out of the ckeditor?
I have seen the below code used in some examples, but it does not work for me in IE (it works fine in Firefox). In IE, selectedText ends up being '[object Object]'.
var selected text = "";
if (oEditor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) {
selectedText = "" + top.oEditor.getSelection().getNative();
}
I tried the below code instead, but the getNative() object returned does not seem to be a standard IE selection object; the createRange() call throws an exception.
var selected text = "";
if (oEditor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) {
if (CKEDITOR.env.ie) {
selectedText = "" + top.oEditor.getSelection().getNative().createRange().text;
} else {
selectedText = "" + top.oEditor.getSelection().getNative();
}
}
There must be an easy way to get the selected text out; can someone clue me in?
I have seen the below code used in some examples, but it does not work for me in IE (it works fine in Firefox). In IE, selectedText ends up being '[object Object]'.
var selected text = "";
if (oEditor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) {
selectedText = "" + top.oEditor.getSelection().getNative();
}
I tried the below code instead, but the getNative() object returned does not seem to be a standard IE selection object; the createRange() call throws an exception.
var selected text = "";
if (oEditor.getSelection().getType() == CKEDITOR.SELECTION_TEXT) {
if (CKEDITOR.env.ie) {
selectedText = "" + top.oEditor.getSelection().getNative().createRange().text;
} else {
selectedText = "" + top.oEditor.getSelection().getNative();
}
}
There must be an easy way to get the selected text out; can someone clue me in?

Re: How to get selected text in IE?
Re: How to get selected text in IE?
var current_editor = "your_editor_name"; if(CKEDITOR.env.ie) { CKEDITOR.instances[current_editor].getSelection().unlock(true); var selected_text = CKEDITOR.instances[current_editor].getSelection().getNative().createRange().text; } else { var selected_text = CKEDITOR.instances[current_editor].getSelection().getNative(); } // So no you can use it to replace something for instance, like I want to do in a custon plugin i've made. CKEDITOR.instances[current_editor].insertHtml('[foo]' + selected_text + '[bar]');Re: How to get selected text in IE?
This code seems to work in IE
This code seems to work in IE up to 8. It doesn't work in IE9 and IE10. So, what's the fix for the latest IE versions??