Name
Window.onfocus: event handler invoked when a window is given focus — JavaScript 1.1:
Synopsis
Function onfocus
Description
The onfocus property of a
Window specifies an event-handler function that is invoked when the
window is given keyboard focus.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onfocus attribute of the <body> or <frameset> tags.
Usage
If your web page has animation or other dynamic
effects, you might use the onfocus event handler to start the
animation and the onblur handler
to stop it, so it runs only when the user is paying attention to the
window.
See Also
Window.blur( ), Window.focus( ), Window.onblur; Chapter 17
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access