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).
Pass a candidate object; branch when it is a browsing context window.
Start with a value that might be a window (context arg, iframe handle, etc.).
Call $.isWindow(obj) — or the official one-liner replacement.
If true, treat it as a window (read document, size, location, …).
If false, handle as a normal object or DOM node instead.
Piece
Required?
Role
obj
Yes
Value to test
Return
—
Boolean — is it a window?
Core idea
—
obj === obj.window identity check
Pseudocode
Pseudocode
function isWindow(obj):
// official jQuery recommendation
return obj != null and obj === obj.window
// Typical use:
if isWindow(context):
doc = context.document
else:
// treat as element / plain object / other
Reference
Cheat Sheet
Keep these facts handy while detecting window objects with jQuery.
Element vs window. The <iframe> node is not a window.
contentWindow. That property holds the iframe’s browsing context.
Check.$.isWindow(win) returns true for same-origin frames.
Cross-origin. Access may throw — wrap reads in try/catch in real apps.
Edge Cases & Pitfalls
Check these before relying on $.isWindow() in plugins.
deprecated
Gone in jQuery 4.0
Copy the official helper: obj != null && obj === obj.window. Do not depend on $.isWindow in new code.
typeof
typeof window === "object" is not enough
Arrays, null (historically), and DOM nodes also look like objects. Use the identity check instead.
iframe
Cross-origin iframes throw
Reading contentWindow or its properties across origins can throw. Catch errors before calling isWindow.
document
Document ≠ window
document lives inside a window. $.isWindow(document) is false — use document.defaultView when you need the window from a document.
Compatibility
Browser Support
jQuery.isWindow() needs jQuery 1.4.3–3.x in the browser. It was deprecated in 3.3 and removed in jQuery 4.0. The official one-liner works in all modern browsers without jQuery.
✓ Deprecated · jQuery 3.3
jQuery.isWindow()
Available with jQuery 1.4.3–3.x in Chrome, Firefox, Safari, and Edge. Prefer obj != null && obj === obj.window for new code. Not present in jQuery 4.0.
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
$.isWindow()jQuery 1.4.3–3.x
Bottom line: Use $.isWindow(obj) only in jQuery 3.x legacy apps. For new projects, use obj != null && obj === obj.window.
Analysis
Performance Notes
Approach
Cost
Best for
$.isWindow(obj)
O(1)
Legacy jQuery context checks
obj === obj.window
O(1)
Modern / vanilla replacement
typeof obj === "object"
O(1)
Too broad — avoid for windows
The check is a couple of property reads. Cost is never the issue — correctness (and same-origin iframe access) is.
Remember
Key Takeaways
Role:$.isWindow(obj) → is this a browser window?
Core test:obj != null && obj === obj.window.
Status: deprecated in 3.3, removed in 4.0.
Also true: same-origin iframe.contentWindow.
One line: a window is the object that equals its own .window — learn $.isWindow for legacy code, ship the official one-liner in new code.
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.