Is there an easy way to know exactly how an element got focus in it's onfocus function? (was the element granted focus because of a mouse click?, because the user tabbed into it?, because it's focus() function was called?).
How an element got focus
Collapse
X
-
If you have a single handler that is called onmouseover and on focus,
and on click and keypress, you can examine the event type to
make some decision about execution.
If you set a handler only to a focus event, focus is all you get.
You could set up a global variable to hold the last event,
and compare it to the current event,
but you'd have to write an assignment in every handler (except focus)
to update it.Comment
-
yes, you are correct.
unfortunately working on a huge project, where I just can't change the way events are handled (1.200+ files with <input onfocus="focusE vent();" /> all everywhere), but fortunately, I was able to work around the issue I had in a completely different manner :)
thank you very much for your help :)Comment
Comment