The jQuery.isWindow() utility returns true when a value is a browser window object — the global page context or an iframe’s contentWindow. This tutorial covers syntax, five worked examples, comparisons with $.type(), the jQuery 3.3 deprecation, and the official one-line replacement.
01
Syntax
$.isWindow(obj)
02
Boolean
true / false
03
window
Passes
04
{} no
Not window
05
iframe
contentWindow
06
3.3+
Deprecated
Fundamentals
Introduction
In browser JavaScript, the global window object is special. It represents the browsing context — the tab or iframe that holds your page. Many values are technically “objects,” but only a true window has the window self-reference property that jQuery checks.
jQuery provides jQuery.isWindow() (also written $.isWindow()) to answer one question: “Is this value a browser window?” jQuery uses that answer internally when working with documents, iframes, and cross-context DOM operations. In jQuery 3.3 the method was deprecated; in jQuery 4.0 it was removed — but legacy plugins still rely on it, so understanding the pattern matters.
Concept
Understanding the jQuery.isWindow() Method
jQuery.isWindow(obj) returns true when obj is a window object — typically the page’s global window or an iframe’s contentWindow.
It returns false for null, primitives, plain objects, arrays, DOM elements, and document. The check is narrow by design: only window objects pass.
💡
Deprecation Notice
Since jQuery 3.3, use obj != null && obj === obj.window instead of $.isWindow(obj) in new code. This tutorial teaches both for maintenance and learning.
Foundation
📝 Syntax
General form of jQuery.isWindow:
jQuery
jQuery.isWindow( obj )
// or
$.isWindow( obj )
Parameters
obj — any JavaScript value to test.
Return value
true if obj is a window object.
false for all other values.
Official replacement (jQuery 3.3+)
jQuery
function isWindow(obj) {
return obj != null && obj === obj.window;
}
// Same result as $.isWindow(obj) in jQuery 3.x
console.log(isWindow(window)); // true
Cheat Sheet
⚡ Quick Reference
Value
$.isWindow()
window
true
iframe.contentWindow
true
{}
false
document
false
document.body
false
null
false
"hello"
false
Compare
📋 $.isWindow vs $.type vs $.isPlainObject
Three checks for three different object categories.
$.isWindow
window only
Browser context object
$.type
"object"
window is "object" too
$.isPlainObject
{} maps
window is not plain
Replacement
obj.window
jQuery 3.3+ pattern
Hands-On
Examples Gallery
Each example uses $.isWindow() (jQuery 3.7.1). Open DevTools or use the Try-it links to run them interactively.
📚 Getting Started
Core window detection — global context and common rejections.
Example 1 — Detect the Global window
The simplest case — the page’s browsing context passes the test.
jQuery uses window detection when resolving document roots across frames. An iframe’s contentWindow is a full window object with the same self-reference pattern as the top-level page.
Example 4 — Guard a Context Parameter
Accept either a window or a DOM element — branch safely.
jQuery
function getDocumentRoot(context) {
if ($.isWindow(context)) {
return context.document;
}
if (context && context.nodeType === 9) {
return context; // already a document
}
if (context && context.ownerDocument) {
return context.ownerDocument;
}
return document;
}
console.log(getDocumentRoot(window) === document); // true
console.log(getDocumentRoot(document.body) === document); // true
jQuery documented this exact replacement when deprecating isWindow. Copy it into utility modules so plugins survive jQuery 4.0 without calling removed APIs.
Applications
🚀 Common Use Cases
Context resolution — distinguish window from element arguments.
iframe plugins — detect contentWindow before DOM queries.
Cross-frame utilities — verify you received a browsing context.
Migration to jQuery 4 — swap in the obj === obj.window helper.
Reject mistaken inputs — block plain objects passed as “context.”
🧠 How jQuery.isWindow() Identifies a Window
1
Reject null
null and undefined return false immediately.
Filter
2
Read .window
Access obj.window — only window objects reference themselves.
Property
3
Strict equality
Compare obj === obj.window — the official replacement logic.
Compare
4
✅
Return boolean
Plain objects, DOM nodes, and arrays fail — only window objects pass.
Important
📝 Notes
Added in jQuery 1.4.3 — used internally across DOM and traversal code.
Deprecated in jQuery 3.3 — removed in jQuery 4.0.
Official replacement: obj != null && obj === obj.window.
$.type(window) returns "object" — not specific enough for window detection.
$.isPlainObject(window) returns false — window is never a plain map.
Works for iframe contentWindow objects the same as the top-level page.
Compatibility
Browser Support
jQuery.isWindow() has been available since jQuery 1.4.3. It works in all browsers where jQuery runs, but was deprecated in jQuery 3.3 and removed in jQuery 4.0.
✓ jQuery 1.4.3+
jQuery jQuery.isWindow()
Present in jQuery 1.x–3.x. Deprecated in 3.3 — use obj === obj.window in new code. Not available in jQuery 4+.
LegacyjQuery 3.x only
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
jQuery.isWindow()Deprecated
Bottom line: Safe in jQuery 3.x maintenance code. For jQuery 4+ or new projects, inline the one-line isWindow replacement instead of calling $.isWindow().
Wrap Up
Conclusion
The jQuery.isWindow() utility answers a narrow but important question: is this value a browser window? It powered jQuery’s cross-context DOM logic for years and remains readable in legacy plugins.
For new code on jQuery 3.3+, prefer the documented replacement obj != null && obj === obj.window. Understand isWindow when maintaining older code — and migrate before upgrading to jQuery 4 — then explore jQuery.isXMLDoc() for XML DOM detection.
Use obj != null && obj === obj.window in jQuery 3.3+ projects
Check window before treating context as a DOM node
Test iframe contentWindow the same as top-level window
Migrate deprecated $.isWindow calls before jQuery 4
Pair with nodeType checks for full context resolution
❌ Don’t
Assume typeof x === "object" means window
Use $.isPlainObject to detect windows
Call $.isWindow() in new jQuery 4+ code — it was removed
Confuse document with window
Skip migration because the deprecated API still “works” in 3.x
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about jQuery.isWindow()
Detect browser windows the jQuery way.
5
Core concepts
🌐01
$.isWindow
Window only
API
✅02
window
Passes
Global
🚫03
DOM
Fails
Reject
🔗04
iframe
contentWindow
Frames
⚠️05
3.3+
obj.window
Migrate
❓ 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, null, and primitives.
Yes. jQuery.isWindow() 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. Both reject window for plain-object merging — 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 across browsers.
Avoid $.isWindow() in new projects. Use the one-line replacement obj != null && obj === obj.window, or test obj instanceof Window where supported. Keep $.isWindow() only when maintaining legacy jQuery plugins.
Did you know?
When jQuery deprecated isWindow, it published the entire implementation as a one-liner: obj != null && obj === obj.window. That pattern works because every browser window object has a window property that points back to itself — a quirk of the HTML spec that jQuery turned into a reliable type test.