JavaScript Window blur() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Method

Definition

Window.blur() is a deprecated method that currently does nothing (MDN). Historically it tried to shift focus away from the current window; that behavior was removed because sites abused it.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call window.blur. Start with this line.

JavaScript
window.blur()
CallWhat it does
window.blur()Primary signature.
window.blur(...)Call with the arguments your case needs.

Built into the browser. Call window.blur(...) (or the global blur(...)) — no import required.

Library declarations
JavaScript
window.blur()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always undefined

JavaScript Examples

Example 1 — Call window.blur()

Invoke the deprecated method. Modern browsers keep the tab focused.

JavaScript
window.blur();
// same as: blur();
console.log("blur() called — expect no tab change");
Try It Yourself

How It Works

  1. Call window.blur(). No arguments.
  2. Browser runs a no-op. Focus is not flipped away.
  3. Log a note. Confirms the script continued normally.
  4. Shorthand. blur() and window.blur() match in browsers.

Example 2 — Return Value

The method always returns undefined.

JavaScript
const result = window.blur();
console.log(result);          // undefined
console.log(typeof result);   // "undefined"
Try It Yourself

How It Works

  1. Store the call. Capture the return value.
  2. Log the value. Always undefined.
  3. Check the type. typeof prints "undefined".
  4. No success flag. You cannot detect a focus flip from the return value.

Example 3 — Listen for the blur Event

React when the user leaves the tab — the practical pattern for apps.

JavaScript
window.addEventListener("blur", () => {
  console.log("Window lost focus");
});

window.addEventListener("focus", () => {
  console.log("Window gained focus");
});

// Switch to another tab, then come back, to see both logs.
Try It Yourself

How It Works

  1. Register listeners. Attach blur and focus on window.
  2. Leave the tab. The browser fires blur.
  3. Return to the tab. The browser fires focus.
  4. Why this matters. You react to the user — you do not force unfocus with window.blur().

Example 4 — window.blur() vs element.blur()

Same name, different targets. Field blur still works; window blur does not move the tab.

JavaScript
const input = document.querySelector("input");
input.focus();
input.blur();           // removes focus from the field ✓

window.blur();          // deprecated no-op — tab stays put ✗
console.log("Compared window.blur() with element.blur()");
Try It Yourself

How It Works

  1. Focus an input. Keyboard focus moves into the field.
  2. Call input.blur(). The field loses focus — this is the everyday API.
  3. Call window.blur(). No tab change in modern browsers.
  4. Rule of thumb. Form fields → element APIs; tab leave → events / Visibility API.

Browser Support

Window.blur() is marked Deprecated on MDN. The method exists widely but is a no-op in modern browsers. Prefer events / Visibility API for real features.

✓ Deprecated · No-op

blur()

Callable everywhere — but it does not unfocus the window in modern engines.

0% Useful focus control
Chrome Present · no-op
Deprecated
Edge Present · no-op
Deprecated
Firefox Present · no-op*
Deprecated
Safari Present · no-op
Deprecated
Opera Present · no-op
Deprecated
HTML element Legacy only

Bottom line: Do not build features on window.blur(). Use the window blur/focus events or visibilitychange instead.

Frequently Asked Questions

According to MDN, Window.blur() does nothing in modern browsers. The call is still available, returns undefined, and does not move focus away from the tab.
Yes. MDN marks Window.blur() as Deprecated. Avoid it in new projects. It is not Experimental or Non-standard.
Hostile sites abused programmatic focus flipping. Browsers removed the ability for scripts to unfocus the current window for security and usability.
No. window.blur() targets the browsing window (and is a deprecated no-op). element.blur() removes keyboard focus from a specific HTML control and is still useful.
Listen for the window blur and focus events, or use the Page Visibility API (document.visibilitychange / document.hidden). Do not rely on window.blur() to force an unfocus.
No parameters. The return value is always undefined.

Next: btoa()

Encode strings as Base64 with window.btoa().

btoa() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful