I’m just curious, why is this event being loaded instead of triggering itself on click .
window.onload=initAll;
function initAll(){
var divPath = document.getElementsByTagName("div")[0];
var theLink = divPath.getElementsByTagName("a")[0];
theLink.onclick = myEvent(theLink);
};
function myEvent (myMan){
myMan.innerHTML="You're my maan,bro!!!";
return false;
};
10x for your kind help
BR
Because you are assigning the result of the function call
myEventHandler(theLink)to thetheLink.onclickproperty. What you are actually trying to do is the following:Which assigns a reference to the myEventHandler function to the
theLink.onclickproperty. The argument passed to that function will be an event object, from which you can determine which object was actually clicked. Alternatively, you can create a closure:This way you get the event object and a reference to the object which you assigned the event handler to, which is what (I guess that) you were trying to do in your code.