Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

Position cursor at the end in textareas


Hi guys,

I am loading a page with textareas containing text.
By the default, the cursor goes at the beginning of the text.

I would like to position the cursor at the end of the text instead.

Does anyone have a quick script to handle this?

Daniele

On May 14, 8:14 am, "Ubi" <ubimm@libero.it> wrote:

> I am loading a page with textareas containing text.
> By the default, the cursor goes at the beginning of the text.

> I would like to position the cursor at the end of the text instead.

  var t=textAreaElement,
  len=t.value.length;
  if(t.setSelectionRange){
    t.setSelectionRange(len,len)
    t.focus()
  }else if(t.createTextRange){
    var rn=t.createTextRange();
    rn.moveStart('character',len)
    rn.select()
  }
Ubi a crit :

> Hi guys,

> I am loading a page with textareas containing text.
> By the default, the cursor goes at the beginning of the text.

When I click in a textarea the cursor goes where I've clicked ...

If I do :  myTextarea.focus();
the cursor comes at the end.

How do you do to get it in 1st position ?

> I would like to position the cursor at the end of the text instead.

<body onload="document.myForm/myText.focus();">

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

Thanks a lot!

> How do you do to get it in 1st position ?

With Firefox, it goes to the end.
With IE, it goes to the beginning.

Thanks for replying!

Daniele

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc