how can I determine the absolute position of a textcursor on a website?
I'm trying to implement a multiline textbox on a website. The textbox should offer a kind of autocompletion while the user is typing. The autocompletion should work similar to what is known as 'Intellisense' in ms visual studio (see screenshot below) and display the autocompletion selection (the list containing "bar", and "foo_bar") just below the textcursor.
I have started with a simple html textarea. I have found several jQuery-Plugins that help me in manipulating the textarea but one very basic problem remains.
How can I know where to position the autocompletion selection (the list containing "bar", and "foo_bar" in the screenshot)?
What html-element,text-editor,technique or plugin could help me to position the autocompletion selection right below the text cursor?
Thanks a lot
JJ
开发者_开发问答Following an example of how "intellisense" looks like:
The JavaScript event.clientX and event.clientY functions will return the coordinates of an event. Bind these functions to an onkeydown event in your textarea to find out where the cursor is positioned.
精彩评论