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

Dan Costea costea.dan at ssi-schaefer.ro
Wed Jan 30 00:28:16 CST 2002


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





More information about the Javascript mailing list