We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

window.onblur Redirect 1


The onblur property can be used to set the blur handler on the window, which is triggered when the window loses focus.


window.onblur = funcRef;
  • funcRef is a reference to the function to be executed.


<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<title>onblur test</title>

window.onblur = blurText;

function blurText() {
  alert("blur event detected!");
  // remove the event to stop an infinite loop!
  window.onblur = '';

<p>click on another window
to fire the blur event for this browser window</p>


DOM Level 0. Not part of any standard.

Document Tags and Contributors

Last updated by: Sheppy,