is it possible in javascript to find if a control has focus?
Printable View
is it possible in javascript to find if a control has focus?
each control has an onfocus event which you could use to set a global variable to indicate which control fired it
Code:<script>
var gControlFocus;
:
function setControl(str){
gControlFocus = str;
}
</script>
:
<input type="text" name="txt1" onfocus="setControl(this.name);">
what if user clicks on empty place or any link, your global variable will still be containing last focused element, I need the currently focused element
Is this any better
Edit: that is probably IE specificCode:document.activeElement.name
YESS! THANKS!