Is it possible to retrieve the word that was right-clicked on along with its x, y coordinates? I attempted the following code:document.onclick=getTextOnClick;
function getTextOnClick(e)
{
console.log(e);
if (window.getSelection) {
txt = window.getSelection();
console.log(">>>"+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);
}
}
This code successfully captures selected text, but is there a way to achieve the same result when simply right-clicking or clicking on a specific word? The event object provides click coordinates - can these be modified to give coordinates of the clicked word instead? Any assistance would be greatly appreciated.