Edit this page

getRange

You can store and restore the exact position of the cursor in the content area using the editor.getSelection().getRange() and editor.getSelection().selectRange(rangeObject) methods. These methods are useful in scenarios when pasting content in the editor from location outside of the control.

Since 2013 Q3 the getRange() method can be used with an additional true argument that returns the W3C standard Document Object Model Range where supported. In IE8 and less (where the W3C range is not supported), the returned object will be the default for IE, the TextRange object or theControlRange object, according to the selected HTML element.

var range = editor.getSelection().getRange(true); //returns an object that represents a restore point.
editor.getSelection().selectRange(range); //Selects the restore point in case you need to restore the cursor to its original location.      

More information about these methods could be found in the following forum thread: "How to maintain the insertion point when I am loading a picture from a script fired from a custom control on the toolbar?".