0

I am using radeditor in my project. I want the text which is immediate after the cursor position or immediate before the cursor position.

I can set html using editor.pasteHtml("html") but how can I get the text before or after that position?

vaibhav shah
  • 4,939
  • 19
  • 58
  • 96

1 Answers1

0

In short you should create a range in the content area of RadEditor

var range = editor.getSelection().getRange();

and obtain the content selection. Try the solution provided in this forum thread: pasteHtml After Node at Cursor Position?.

You can find additional information about the ranges in these articles:

http://www.wrox.com/WileyCDA/Section/JavaScript-DOM-Ranges-Page-2.id-292302.html http://www.quirksmode.org/dom/range_intro.html http://msdn.microsoft.com/en-us/library/ms535872%28VS.85%29.aspx

Once you create a range in the editor, you can use the GetCaretPosition function from this thread: JavaScript get word before cursor

Community
  • 1
  • 1
Rumen Jekov
  • 1,665
  • 2
  • 17
  • 19
  • I want to get text which is before & after cursor position. Not set text. – vaibhav shah Nov 11 '14 at 11:37
  • Once you create a range in the editor, you can use the GetCaretPosition function from this thread: http://stackoverflow.com/questions/9959690/javascript-get-word-before-cursor – Rumen Jekov Nov 11 '14 at 12:14