PDA

View Full Version : capturing tagname in moz & NS7


x_goose_x
09-21-2002, 01:39 PM
The following works in ie:

document.onmousedown=new Function("alert(event.srcElement.tagName)");

How can it be moded to work in ns?

nolachrymose
09-21-2002, 03:31 PM
document.getElementById("PrxOff").addEventListener("mouseover",new Function("evt","alert(evt.tagName);"),false);

Hope that helps!

Happy coding! :)

jkd
09-21-2002, 05:17 PM
That won't quite do it...

Just to stay with the document.onmousedown desire:

document.onmousedown = function(event) {
alert(event.target.tagName);
}

Remember, in Gecko, TextNodes are valid EventTargets, therefore you may want to use event.target.nodeName, which will be "#text" in the case of a text node, of which you probably want event.target.parentNode.tagName, or it will be "TAGNAME" if that is the deepest node that it can target.