Okay, round 2 (IE died on me before I got to post last time)
The first way ou are calling a function requires it to be called manually. So it could only act when
myFunction() is called.
The second case is used to assign objects and methods functions. For instacne if you used this code:
CODE
document.onerror = function(msg,url,l){
txt="There was an error on this page.\n\n";
txt+="Error: " + msg + "\n";
txt+="URL: " + url + "\n";
txt+="Line: " + l + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
It will alert the error automatically every time an error occures in the JS. (granted this is a little different than the normal implementation of the onerror function, and thus it may not work quite right, but I think you should be able to get the point off of it).
Hope that helps.