News for hackers. Stuff that matters.
Re:Ask HN: Who's Hiring? (take 2) by shiranaihito on Thursday August 13, 2009 @05:12AM (#760350)
What's wrong with "element.onmouseover = fn", by the way?
Re:Ask HN: Who's Hiring? (take 2) by bd on Thursday August 13, 2009 @08:16AM (#760567)
In this way you can attach just one function to the event. Other way allows for more flexibility.

http://www.quirksmode.org/js/events_tradmod.html

http://www.quirksmode.org/js/events_advanced.html

But I guess interviewer was not implying onmouseover was "wrong", just probing how much does candidate know about the topic.

Re:Ask HN: Who's Hiring? (take 2) by shiranaihito on Thursday August 13, 2009 @11:46PM (#762312)
In this way you can attach just one function to the event. Other way allows for more flexibility.

Alright. To me it sounded a bit like onmouseover was used only by bad programmers.

Re:Ask HN: Who's Hiring? (take 2) by nostrademons on Friday August 14, 2009 @12:37AM (#762372)
I'm kinda curious why you would ever use onmouseover when attachEvent/addEventListener are available? I just took out the remaining calls to .onEvent handlers in websearch's JS library - the only browsers that don't support the W3C/IE event models are so ancient that they don't get JS anyway, and there's not much point using a method that's unnecessary on modern browsers and does the wrong thing anyway.

So yeah, my interviewer wasn't implying that onmouseover is used only by bad programmers, but I am. ;-)

Re:Ask HN: Who's Hiring? (take 2) by shiranaihito on Friday August 14, 2009 @11:28AM (#763175)
Maybe I only need one event handler, or maybe I've baked a function that calls another function?

Besides, I'd rather use one standard method that works across browsers than choose one based on the user's browser. Would you call that bad programming? :p

Nowadays I generally use jQuery (.click(fn)) though.

Re:Ask HN: Who's Hiring? (take 2) by nostrademons on Friday August 14, 2009 @12:16PM (#763292)
Ah, okay. Most of the stuff I've worked on adds events through a library (eg. jQuery.click(fn)), and there's no reason for that library to use onmouseover etc.