[Javascript] Get the position of the cursor in a textarea?

Joost Kahmann J.Kahmann at fcj.hvu.nl
Tue Jun 24 04:40:53 CDT 2003


Hi All

Try this:

function zetFocus()
	{
	 	this.f_int.Naam.focus() ;
	}
<body  onLoad="zetFocus(0,1);">
'F_int' is the name of the form.
'Naam' is the name of the focussed element.

 _
/\_\
\/_/  Joost



> ----------
> From: 	alwang at micron.com
> Reply To: 	[JavaScript List]
> Sent: 	maandag, 23 juni 2003 22:42
> To: 	Javascript at LaTech.edu
> Subject: 	[Javascript] Get the position of the cursor in a textarea? 
> 
> 
> David, 
>    I also have such problem, how do you fix this problem?
> 
>     Thanks,
> 
> Alex.
> 
> 
> Dan- I just tried it and it actually gives the position of the mouse and not
> the blinking text cursor (sorry I didn't make that clear).  
> 
> David
> 
> > -----Original Message-----
> > From: Dan Costea [mailto:costea.dan at ssi-schaefer.ro]
> > Sent: Tuesday, January 29, 2002 10:28 PM
> > To: javascript at LaTech.edu
> > Subject: Re: [Javascript] Get the position of the cursor in a 
> > textarea?
> > 
> > 
> > Yes, it is possible. I didn't made the code for NS, but with 
> > IE4+ you can
> > run the following code:
> > 
> > <body onMouseMove="document.all['asdf'].innerHTML = 'xPos: ' 
> > + event.x +
> > '<br>yPos: ' + event.y ">
> > <div id="asdf"></div>
> > <br>
> > <textarea rows=4 cols=35>this is a textarea ... </textarea>
> > </body>
> > 
> > 
> > 
> > 
> > 
> > > Hi all.  Is it possible to get the position of the cursor 
> > in a textarea?
> > > E.g. let's say I have:
> > >
> > > Hello there, Welcome to 12345 company.
> > >
> > > in a textarea, and the cursor is currently after the word 
> > Hello.  So I
> > would
> > > like a value of 6 returned by such a javascript function.  Thanks!
> > >
> > > David
> > > _______________________________________________
> > 
> > 
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> > 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 


More information about the Javascript mailing list