How to get the word on which a click was made in javascript
<p>can we get the word on which a right click was made and x,y coordinates of that word ?
i tried:
    <code>document.onclick=getTextOnClick;</code></p>

<pre><code>function getTextOnClick(e)
{
    console.log(e);
    if (window.getSelection) {
        txt = window.getSelection();
            console.log("&gt;&gt;&gt;"+txt);
    } else if (document.getSelection) {
        // FireFox 
        txt = document.getSelection();
            console.log(txt);
    } else if (document.selection) {
        // IE 6/7 
        txt = document.selection.createRange().text;
            console.log(txt);
    }
}
</code></pre>

<p>Now this code works if i select some text, but can i get the same when i just eight click or click on certain word ? And event object is giving me coordinates of click. can i get coordinates of the word on which the click was made ? Plz help</p>
