File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes how to get text under current corsor position Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to get text under current corsor position" Watch "how to get text under current corsor position" New topic

how to get text under current corsor position

snehal Pa

Joined: Apr 18, 2006
Posts: 1
Hi all

How can I get the word(text) under mouse pointer from my web page?
I want to get the exact word under the mouse pointer from an html page & send it for further processing.

I am able to get current position of the mouse pointer on the html form...
But then how to get the text at that position...?
this text can be from the text box, toolbar, caption of button anything from my form

Thanks & Regards,

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This is not a servlet question, moving to HTML and Javascript

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
You could get it if they highlight th word with createText range, but you will not be able to figure out the word with just the mouse position. Different resolutions and such will not all you to do that. You could rip apart the entiore document.Add spans with mouseovers, but you are talk a long process that will make you users wait forever.

I agree. Here's the link:
subject: how to get text under current corsor position
Similar Threads
help about myeclipse??
How to retrieve and store pointers/positions as numbers?
To get the coordinates of mouse pointer...
JTextArea - Determine index / position from MouseEvent
stop blinking cursor in Eclipse3.2 in Linux