Forum Moderators: open

Message Too Old, No Replies

How to get location of blinking cursor when user select a field?

I wish to get the blinking cursor location, not the mouse location.

         

alex298

4:32 am on Aug 24, 2008 (gmt 0)

10+ Year Member



Hello,

I just start learning JavaScript. How can I get the "actual x,y location" of the blinking cursor when a field is onfocus, either by user select the field or by TAB.

I tried many online mouse and cursor JavaScript codes but they are not what I want. The codes only get the mouse location, not the blinking cursor location when user select a field. The problem of the existing codes are:

1. When a user place the mouse cursor near the end of the field and select, the cursor location is showing at this location, not the real cursor location which is blinking at the beginning of the field.

2. When user put the mouse anywhere on the screen and used TAB to set focus to the field, the cursor or mouse location is only showing where the mouse is, not the blinking cursor.

Please help.

Thanks and best regards

Alex

phranque

5:24 am on Aug 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what you really want is the "focus", not the cursor location.
but i'm not sure how you can get the name of the input field that has the focus.
perhaps you could use the onfocus event for each input field to set a global javascript variable with the field name and then retrieve the field name when you fire the onclick event for the cursor.

alex298

6:33 am on Aug 24, 2008 (gmt 0)

10+ Year Member



Hello,

Thanks for your help. Yes, I want the location of the "focus".

Actually I am also thinking to use the onfocus event for each input field. Actually I am also thinking the possibilities of getting the location of each text field.

Could you please advise more how can I use the onfocus event for each input field to set a global javascript variable with the field name and then retrieve the field name when you fire the onclick event for the cursor?

Best regards

Alex