Click to See Complete Forum and Search --> : Determinig what element has focus


NZL
11-04-2003, 05:30 PM
Hi,

i'm trying to figure out how you determine what item is currently in focus. So for example if there are two input boxes like so:

<input type=text name=input1>


<input type=text name=input2>

And a user clicks on input1 then i can check focus with something like

if (current.focus = input1) then
alert 'current focus is input1'

Is this possible? I should make it clear that i DON'T want an event such as onClick or onFocus to do this, I just want to be able to tell what element currently has focus at any time.

Does this make sense?

Thanks heaps.

:)

gil davis
11-04-2003, 05:41 PM
Is this possible?No.I should make it clear that i DON'T want an event such as onClick or onFocus to do this, I just want to be able to tell what element currently has focus at any time.An event is your only choice. You can make your own "hasFocus" parameter, but the only way you can make it update is by using the onFocus event handler.