Name

Window.onblur: event handler invoked when the window loses keyboard focus — JavaScript 1.1:

Synopsis

Function onblur

Description

The onblur property of a Window specifies an event-handler function that is invoked when the window loses keyboard focus.

The initial value of this property is a function that contains the semicolon-separated JavaScript statements specified by the onblur attribute of the <body> or <frameset> tags.

Usage

If your web page has animation or other dynamic effects, you can use the onblur event handler to stop the animation when the window doesn’t have the input focus. In theory, if the window doesn’t have the focus, the user probably can’t see it or isn’t paying attention to it.

See Also

Window.blur( ), Window.focus( ), Window.onfocus; Chapter 17

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.