Allows you to assign an event handler to an element.
function addEvent(obj, eventName, callback){
if (obj.addEventListener){
obj.addEventListener(eventName, callback, false);
} else if (obj.attachEvent){
obj.attachEvent("on"+eventName, function(e){ return callback.call(obj, e); });
}
}
void addEvent (element obj, string eventName, function callback)
obj - The target element.
eventName - The type of event to record.
callback - The function that will be executed at the outbreak of the event.
No value is returned.
addEvent(window, "load", function() {
alert("the page has successfully loaded!");
});