In traditional event registration model:
function foo(e){console.log(e.type)}
document.getElementById("#id").onclick=foo;//registered event handler
But in inline event registration model:
<a href="#" onclick=foo(event)>clck</a>
console.log(a.click)===function click(){foo(event)}
Can't event object be used directly within the function foo rather than pass as a function argument.Since event object being used within the click function is not passed by the browser we are manually passing it.Why passing event object within the event handler function dont work?
eventisn't defined in the global context which is how you are trying to access it to pass it to your function. Anyway, don't use inline events.eventis defined in global context in some browsers (Internet Exporter, IIRC). Attributes do need to be quoted, though. @Maizere, you're counting on the help of random strangers who aren't getting paid to help you. Try waiting more than 18 minutes before you start complaining that no one has answered you yet - especially when it's the middle of the night in America, where many of SO's users are.foo("bar")and you should receivebarin your function as a parameter.