Jump to content

Focus on an object


Recommended Posts

Hello,I found two methods about focus, focus() to set the focus and blur() to remove the focus, but i didn't find any method to know if an object has the focus or not.Is anybody tried to use a "hasFocus()" method in Javascript?If you have some idea, please help me.Tks, Emmanuel.

Link to comment
Share on other sites

hmm...your right.try thisJavaScript

var hasFocus = false;function setFocusState(focusState){     hasFocus = focusState;}


<object...onfocus="setFocusState(true)" onblur="setFocusState(false)" ...>

then you can check the state of hasFocus when you need to kow if the object has focus.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...