Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emulating Home Key in Textarea

Status
Not open for further replies.

Behrooz

Programmer
May 10, 2001
6
CA
To the experts:
I wonder if it is possible at all.

I have a textarea, and I want to create a "Home key" effect on this textarea , on click of a button.

Like this:
function OnClickofButton1()
{
....
document.form1.textarea1.focus();
document.form1.textarea1.[Jump to Home, as if Home Key is pressed].
}

Is it possible at all? If it is possible, how? I want it in IE only.

Thank you.
 
<textarea ACCESSKEY=h>

Will make the cursor jump to the textarea upon the user pressing the &quot;Alt-H&quot; key combination.

:)
Paul Prewett
 
Thank you Paul.

However, my problem was vice versa of this solution.

I don't want to jump to textarea, I want to jump to &quot;Home&quot; that is the beginning of the line, when the user is in the textarea. But I don't want to user to press Home Key on the keyboard. The user clicks on the button on the screen, and the cursor inside the textarea wil move to the beginning of the line.

I can put this question this way:

Can we change the position of the cursor inside a textarea programmatically? Can we move the cursor inside the textarea by some javascript commands or functions?

Thank you.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top