Connecting Tech Pros Worldwide Forums | Help | Site Map

get word under cursor?

Timo
Guest
 
Posts: n/a
#1: Jul 23 '05
Assume we have this html:

<span>the quick brown fox</span>

and the mouse is hovering over the word "fox". Using javascript, is it
possible to determine the word under the mouse *without* introducing
additional elements such as an anchor?

//undesirable:
<span>the quick brown <a id='fox'>fox</a></span>

Thanks
Timo



Dietmar Meier
Guest
 
Posts: n/a
#2: Jul 23 '05

re: get word under cursor?


Timo wrote:
[color=blue]
> <span>the quick brown fox</span>
>
> and the mouse is hovering over the word "fox". Using javascript, is it
> possible to determine the word under the mouse *without* introducing
> additional elements[/color]

No. The browser doesn't know about words. In the browser's object model,
the text node "the quick brown fox" is atomic.

ciao, dhgm
Martin Honnen
Guest
 
Posts: n/a
#3: Jul 23 '05

re: get word under cursor?




Timo wrote:
[color=blue]
> Assume we have this html:
>
> <span>the quick brown fox</span>
>
> and the mouse is hovering over the word "fox". Using javascript, is it
> possible to determine the word under the mouse *without* introducing
> additional elements such as an anchor?[/color]

In IE (on Win at least) and in Mozilla browsers it is possible, see
<http://www.faqts.com/knowledge_base/view.phtml/aid/33674>
for details.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread