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?
Hi,
I think I found a solution. It doesn't make sense to me, but it works.
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??