Background:
I'm writing a script (in VBA, if that matters) to input data into a web-based system. Some of the system's validation is only run when a field is focused, so I've been calling .Focus
on the fields in VBA to force it to run. But that steals the systemwide focus; rather annoying if I am doing anything else while the job is running.
I want the validation to be triggered without stealing the focus. So I am trying to directly call whatever event handler is registered to the input field.
Problem:
All event handlers in the web app are added with element.attachEvent()
, which means the onfocus
and onblur
properties (which I believe are the ones I want) are not set.
Is there any way to retrieve the handlers without resorting to even more evil hacks?
Alternatively, is there a better way to do this without having to find the event handlers? I'm pretty new to JavaScript, so I could easily be missing something.
Edit: Is there any other reason the focus might be stolen by the VBA code? I cannot find any other references to .Focus
or even AutoIt's WinActivate
, but even with the suggestions here, the problem still occurs.