...

View Full Version : focus cursor at certain position inside textarea



ventura
07-08-2003, 12:23 AM
is there a way to set the cursor to be at a certain point in a text area when the page is loaded?

i have a prefilled text area and want the cursor to show up after the text inside of it.



<html>
<body>
<form name="form1" id="form1">
<textarea name="field1" cols="60" rows="10" id="field1">I want the cursor to show up after this line. </textarea>
</form>
</body>
</html>

jkd
07-08-2003, 12:57 AM
Assume "tarea" is a reference to the textarea:

tarea.setSelectionRange(tarea.length, tarea.length);

This is for Gecko-based browsers, such as Mozilla, Firebird, NS7, Camino, etc.

There is some way using a TextRange object in Win/IE of doing this, but I don't recall it off the top of my head.

ventura
07-08-2003, 01:05 AM
thanks. IE is actually the browser that i'm targeting. if anyone knows how to do this in IE, i'd appreciate it.

Kor
07-08-2003, 09:46 AM
There's method setEndPoint but... hm, I never use it... I am not sure that it might help you...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum