Opened 14 years ago

Closed 14 years ago

#5950 closed Bug (invalid)

getSelection IE7 & IE6 = is null or not an object

Reported by: thinkap Owned by:
Priority: Normal Milestone:
Component: General Version: 3.3.1
Keywords: Cc:

Description

When i try to extract the selected text from the editor i receive the error "getSelection is null or not an object" only happens in ie6 & ie7. it works great in ie8, firefox, chrome & safari.


var editor_name = 'email_ckeditor';


var mySelection = CKEDITOR.instances[editor_name].getSelection();


if (CKEDITOR.env.ie) {
    mySelection.unlock(true);
    selectedText = mySelection.getNative().createRange().text;
} else {
    selectedText = mySelection.getNative();
}

alert( selectedText );
	

also tried without luck

var editor_name = 'email_ckeditor';


if (CKEDITOR.env.ie) {

selection = CKEDITOR.instances[editor_name].getSelection().document.$.selection.createRange().text;
			
} else {

selection  = CKEDITOR.instances[editor_name].getSelection().getNative();
};

alert( selection );

Change History (1)

comment:1 Changed 14 years ago by thinkap

Resolution: invalid
Status: newclosed

The problem with IE is that it doesn't preserve the selection on different frames. So, in the exact moment you click the link, the selection is lost in the editor.

The solution for it, fortunately, is quite simple. It's enough to add unselectable="on" to you <a> element, so it'll not grab the selection when clicking on it.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy