jQuery isWindow() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Utilities

Definition

jQuery.isWindow(obj) (alias $.isWindow) returns true when obj is a browser window — the current page window or an iframe’s contentWindow (added in jQuery 1.4.3).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$.isWindow(obj)  → true | false

$.isWindow(window)  // true
$.isWindow({})      // false
$.isWindow(document.body)  // false

// Official replacement (jQuery 3.3+):
function isWindow(obj) {
  return obj != null && obj === obj.window;
}
CallWhat it does
isWindow()Learn jQuery.isWindow(): detect browser window objects vs plain objects and DOM nodes, official replacement after deprecation, examples, pitfalls, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Start with a value that might be a window (context arg, iframe handle, etc.).
Step 2Call $.isWindow(obj) — or the official one-liner replacement.
Step 3If true, treat it as a window (read document, size, location, …).

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.

jQuery Examples

Example 1 — Detect the Global window

The current page browsing context passes the test.

jQuery
console.log($.isWindow(window));              // true
console.log(window === window.window);        // true
console.log($.isWindow(self));                // true (same window)
Try It Yourself

How It Works

  1. Global window. $.isWindow(window) is true for the page context.
  2. Self reference. A window’s .window property points back to itself.
  3. Alias. self refers to the same window in normal pages → also true.

Example 2 — Values That Are Not Windows

Plain objects, the document, and DOM nodes all fail.

jQuery
console.log($.isWindow({}));              // false
console.log($.isWindow(document));        // false
console.log($.isWindow(document.body));   // false
console.log($.isWindow(null));            // false
Try It Yourself

How It Works

  1. Plain object. {} has no .window self-link → false.
  2. Document. The document is not a window (it lives inside one).
  3. Element. DOM nodes are host objects, not browsing contexts.

Example 3 — Official Replacement Helper

Copy the one-liner from the jQuery API for jQuery 4+ or vanilla code.

jQuery
function isWindow(obj) {
  return obj != null && obj === obj.window;
}

console.log(isWindow(window));  // true
console.log(isWindow({}));      // false
console.log($.isWindow(window) === isWindow(window));  // true
Try It Yourself

How It Works

  1. Null guard. obj != null skips null and undefined.
  2. Identity. obj === obj.window is true only for Window objects.
  3. Parity. Matches $.isWindow on jQuery 3.x for normal cases.

Frequently Asked Questions

jQuery.isWindow(obj) returns true when obj is a browser window object — the global window or an iframe's contentWindow. It returns false for plain objects, DOM elements, document, null, and primitives.
Yes. It was deprecated in jQuery 3.3 and removed in jQuery 4.0. jQuery recommends reimplementing it as: function isWindow(obj) { return obj != null && obj === obj.window; }
jQuery uses window detection internally when deciding whether a context is the global browsing context or an iframe — for example when resolving document roots and comparing execution contexts.
isPlainObject returns true for simple {} maps. isWindow returns true only for window objects. $.isPlainObject(window) is false, and $.isWindow({}) is false.
No. typeof window is "object", but so are arrays and DOM nodes. isWindow uses the obj === obj.window identity check that specifically identifies window objects.
Yes, when you can access the iframe's contentWindow (same-origin). Cross-origin iframes block access and throw a security error — catch that before testing.

Next: isXMLDoc() Method

Learn how jQuery detects XML document nodes versus HTML.

isXMLDoc() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

9 people found this page helpful