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

RadEditor setFocus in the end of the content

2 Answers 69 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 14 Sep 2012, 02:45 PM
Hi !

I need to set the focus in the end of the radeditor content. The content is already in the editor when the editor loads and need to set the focus after this content..

Please help..

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Sep 2012, 09:36 AM
Hi Nick,

Try the following code to achieve your scenario.

JS:
<script type="text/javascript">
 function OnClientLoad()
 {
  setTimeout(function () {
  var editor = $find("<%= RadEditor2.ClientID %>");
  editor.setFocus();
  var doc = editor.get_document(); //or get_Document() in earlier versions such as Q1 2007
  doc.execCommand("SelectAll", null, false);
  /Collapse selection to the end
  editor.getSelection().collapse();
  }, 100);
 }
</script>

Hope this helps.

Thanks,
Shinu.
0
Nick
Top achievements
Rank 1
answered on 28 Sep 2012, 07:04 AM
Thanks Shinu!

It worked..
Tags
Editor
Asked by
Nick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nick
Top achievements
Rank 1
Share this question
or