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,