The onfocus
property of the GlobalEventHandlers
mixin is an EventHandler
that processes focus
events on the given element.
Mozilla exists to build the Internet as a public resource accessible to all because we believe open and free is better than closed and controlled.
The focus
event is raised when the user sets focus on an element.
- Camino is a Mac OS X-native browser built on Mozilla’s Gecko rendering engine.
- Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
For onfocus
to fire on non-input elements, they must be given the tabindex
attribute (see Building keyboard accessibility back in for more details).
Note: The opposite of onfocus
is onblur
.
Syntax
Value
functionRef
is a function name or a function expression. The function receives a FocusEvent
object as its sole argument.
Example
Firefox Focus For Android
This example uses onblur
and onfocus
to change the text within an <input>
element.
HTML
JavaScript
Mozilla Focus For Windows 10
Result
Try clicking in and out of the form field, and watch its contents change accordingly.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'onfocus' in that specification. | Living Standard |
Mozilla Focus Browser
Browser compatibility
BCD tables only load in the browser
In contrast to IE, in which almost all kinds of elements receive the focus
event, almost all kinds of elements on Gecko browsers do NOT work with this event.
See also
focus
event- Related event handler:
GlobalEventHandlers.onblur
After a decade-long run, Camino is no longer being developed, and we encourage all users to upgrade to a more modern browser. Camino is increasingly lagging behind the fast pace of changes on the web, and more importantly it is not receiving security updates, making it increasingly unsafe to use.
Fortunately, Mac users have many more browsers to choose from than they did when Camino started ten years ago. Former Camino developers have helped build the three most popular – Chrome, Firefox, and Safari – so while this is the end of Camino itself, the community that helped build it is still making the web better for Mac users.
Mozilla Focus Android
Thank you to all our loyal users, and to everyone who contributed in countless ways over the years to make Camino what it was.