... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2007-05-15

Event-Handling in FF and IE

The following snippet can be used in either Firefox or Internet Explorer to recover the target document node from a click event:

window.onload = function() {
    document.body.onclick = function(suppliedEvent) {
        var target;
        if (undefined != suppliedEvent) {
            target = suppliedEvent.target; // Firefox
        } else if (undefined != event) {
            target = event.srcElement; // IE
        } else {
            return; // some other browser?
        }
        alert(target.nodeName);
    };
}

Blog Archive