开发者

html onfocus tab vs page load

Let's say I hav开发者_如何转开发e an onFocus event for a text box. That event triggers when the user tabs into that box, as expected. But it also seems like the event triggers when the box is selected, and then the window is covered and then uncovered, by switching tabs, opening then closing another application, etc. Is there a way to make it so that the event triggers only by tabbing (or mouse-clicking) the text box, and NOT by covering then uncovering the window?


You can use an onClick event. This will only trigger the event on the click though, not tabbing. You could also use onKeyDown which would trigger on any key press, but would also trigger when the user tabbed away from the textbox.

http://jsfiddle.net/kBzAu/2/


when one goes away from page, you may use window.document.onblur=function(){disable all onFocus};
and re activate them with window.document.onfocus=function(){enable all onFocus};

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜