JavaScript Window frameElement Property

Definition
window.frameElement is the <iframe> (or frame) element that embeds this window, or null on a top-level page.
Syntax
Read window.frameElement with no parentheses.
| Call | What it does |
|---|
window.frameElement | The iframe element containing this window, or null. |
Window property in browsers. No import required.
Parameters
| Parameter | Description |
|---|
| window.frameElement | Read-only or assignable depending on the property. No function arguments. |
Return Value
| Return Value | Description |
|---|
| * | The iframe element containing this window, or null. |
JavaScript Examples
Example 1 — Basic Read
Beginner example for window.frameElement.
console.log(window.frameElement);
console.log(window.frameElement === null);
How It Works
- Step. Top-level tutorial pages return null.
- Step. Inside a same-origin iframe you get the element.
Example 2 — Practical Use
Beginner example for window.frameElement.
const embedded = window.frameElement !== null;
console.log(embedded ? "inside frame" : "top-level");
How It Works
- Step. A quick embed check for same-origin cases.
Compatibility
Browser & Runtime Support
window.frameElement is a standard Window property in browsers.
✓ Browser Window API
window.frameElement
Available in all modern browsers. Not used in plain Node.js without a DOM.
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full supportwindow.frameElement Excellent
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Frequently Asked Questions
The embedding iframe element, or null when not embedded (or blocked).
Cross-origin parents hide the element. Same-origin iframes can read it.
Use parent and top to walk the frame tree.
Open the Window Properties index for every property in this series.
Browse more properties
Continue through the Window properties list.
Next → CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author
Developer, cloud engineer, and technical writer
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