get word under cursor?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Timo

    #1

    get word under cursor?

    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

    #2
    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

    Comment

    • Martin Honnen

      #3
      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/

      Comment

      Working...