Ticket #5950 (closed Bug: invalid)

Opened 4 years ago

Last modified 4 years ago

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

comment:1 Changed 4 years ago by thinkap

  • Status changed from new to closed
  • Resolution set to invalid

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 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy