|
-
Mar 19th, 2003, 07:13 AM
#1
Thread Starter
Junior Member
focus question
is it possible in javascript to find if a control has focus?
-
Mar 19th, 2003, 07:48 AM
#2
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);">
-
Mar 19th, 2003, 07:58 AM
#3
Thread Starter
Junior Member
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
-
Mar 19th, 2003, 08:35 AM
#4
Is this any better
Code:
document.activeElement.name
Edit: that is probably IE specific
Last edited by DeadEyes; Mar 19th, 2003 at 08:39 AM.
-
Mar 19th, 2003, 08:54 AM
#5
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|