Connecting Tech Pros Worldwide Help | Site Map

get word under cursor?

  #1  
Old July 23rd, 2005, 06:33 PM
Timo
Guest
 
Posts: n/a
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


  #2  
Old July 23rd, 2005, 06:33 PM
Dietmar Meier
Guest
 
Posts: n/a

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
  #3  
Old July 23rd, 2005, 06:34 PM
Martin Honnen
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Integrating Windows API into C# code StanislavPetrov answers 0 August 24th, 2007 07:44 PM
Can Access create Word documents? etuncer@gmail.com answers 4 February 4th, 2007 01:15 AM
i want to get text under mouse cursor in any window or window scren mitendra answers 5 November 20th, 2005 12:30 PM
Catching events outside the application... Billy Porter answers 3 November 17th, 2005 10:47 AM