This is a migrated thread and some comments may be shown as answers.

Set Selection Position

1 Answer 143 Views
Editor
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 08 Apr 2008, 01:34 PM
Hi

We can use the client side api to get the selection as follows:

var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object

var theSelectionObject = editor.getSelection();

var theSelectedElement = theSelectionObject.getParentElement();

theSelectionObject.getHtml()


However is there a way we can set the selection range? ie set the start postion to start position + 1?

Thanks
David

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Apr 2008, 03:44 PM
Hi David,

The requested feature is not supported out-of-the box by RadEditor and it does not offer client-side API for it.

That is why you should implement your scenario using the underlying API of the browser. You need to get a reference to the RadEditor Document with editor.get_document(); and create a range.

//get a reference to the document object in the editor content area
editor.get_document();
//You can create a range in IE like this:
editor.get_document().selection.createRange();


After that you will be able to use the following methods

duplicate(), move(), moveStart(), moveEnd() and select()
which will allow you to control the selection in the content area.


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
David
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or