Determine what triggered focus event?
问题 I need to determine what caused a focus event. Ideally, I want to differentiate between a click, a tab/keyboard input, and a manual (via code) trigger. How can I do this? I'm looking at the event object, but I'm not seeing anything too useful. 回答1: If the focus comes from a $x.focus() call, then the event won't have an originalEvent property because there was no event from the browser so: if(ev.hasOwnProperty('originalEvent')) { // Focus event was manually triggered. } To differentiate