Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting selected text with CKEditor Plugin on IE

I have made a plugin for CKEditor, but it relies on the currently selected text.

In FF and Chrome I can use:

var selectedText = editor.getSelection().getNative();  

but this doesn't work in IE and I only get [object Object]

Any suggestions?

like image 423
Alex Avatar asked Mar 05 '10 09:03

Alex


1 Answers

This is what I use:

var mySelection = editor.getSelection();

if (CKEDITOR.env.ie) {
    mySelection.unlock(true);
    selectedText = mySelection.getNative().createRange().text;
} else {
    selectedText = mySelection.getNative();
}
like image 181
Luckyrat Avatar answered Sep 18 '22 07:09

Luckyrat