Determining nodeType of context-clicked element
"Jack" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I'm writing an extension which will do something with a word
that is context-clicked on (unselected text). I currently have the
following code, but the nodeType returned when context-clicking on text is
1, instead of 3.
Here's a snippet of the overlay.js file:
[code]
var ffextension = {
onLoad: function() {
this.initialized = true;
document.getElementById("contentAreaContextMenu")
.addEventListener("contextmenu", onMenuItemCommand, false);
},
onMenuItemCommand: function(e) {
var node = e.rangeParent;
var pos = e.rangeOffset;
if (node.nodeType === 3 || node.nodeType === 4) {
// code never gets here, nodeType is 1 even when
// right-clicking on text or input box
// the nodeName is xul:hbox
}
},
window.onload = onload;
[/code]
How can I get retrieve the context as a text node, if I am clicking on text?
Any help would be appreciated,
Jack