how to get text below mouse pointer

S

snehal

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,
Snehal.
 
T

Travis Newbury

snehal said:
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...?

google "dhtml text at cursor". You will be rewarded with tons of
examples.
 
J

Jonathan N. Little

David said:
I don't think that he wanted you to include the quotation marks.
Just a word of warning...many are very old JavaScript, that is pre-W3C
DOM browsers with *great* browser sniffing like:

if(document.layers){ blah; }
if(document.all){ blah; }

and nary a

if(document.getElementById){ the blah that you should code for; }

so for the newbie if you do not know what I am talking about then much
of what you see with above search will not yield much help. I would
advise using CSS methods

Google "CSS tooltips" and steer clear of JavaScript solutions.
 
F

frederick

Jonathan said:
Google "CSS tooltips" and steer clear of JavaScript solutions.

I don't believe that's what the OP was after; (s)he wanted to be able
to "select" a word, say amidst some text, and then feed it to a script.
I suppose a bit like how you can double-click on a word in a word
processor and then access a context-sensitive menu for a spell-check or
whatever.

I have absolutely no idea how (or why) you'd go about doing it, though.
One for comp.lang.javascript or similar, perhaps?
 
J

Jonathan N. Little

I don't believe that's what the OP was after; (s)he wanted to be able
to "select" a word, say amidst some text, and then feed it to a script.
I suppose a bit like how you can double-click on a word in a word
processor and then access a context-sensitive menu for a spell-check or
whatever.

I have absolutely no idea how (or why) you'd go about doing it, though.
One for comp.lang.javascript or similar, perhaps?


Ah, yes I see you are correct by studying OP's initial post. I am fairly
sure you cannot do what OP wishes with HTML even with JavaScript to
assist. In fact finding the exact mouse position with respect to the
document and viewport is a major challenge for cross-browser support

http://www.quirksmode.org/js/events_properties.html
Javascript - Event properties

let alone 'recognizing' what word is where within the flow of the
document! Where it was varies by browser, viewport size, font size and
font used by user's system! Maybe some java applet or within a flash
object but anywhere in a webpage? Don't think it is possible?
 
S

snehal

Hi all,

Thanks for ur replies
Is there is any way to get text selected by the user on form.?
but again the text can be from text box,caption of button, Labels,or
simple text on form...


Thanks once again
Snehal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top