allows other libraries to use .onerror as well.
i think this is what jquery does:
if ( window.addEventListener ) {
window.addEventListener(eventname, func, false);
} else {
window.attachEvent(eventname, func); // IE <=8 (not sure if event name is the same)
}