|
|
 |
 |
 |
 |
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
|
 |
 |
 |
 |
|