JavaScript Window frameElement Property

Beginner
5 min read
Updated: Nov 2026
3 examples
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.

JavaScript
window.frameElement;
CallWhat it does
window.frameElementThe iframe element containing this window, or null.

Window property in browsers. No import required.

Parameters

ParameterDescription
window.frameElementRead-only or assignable depending on the property. No function arguments.

Return Value

Return ValueDescription
*The iframe element containing this window, or null.

JavaScript Examples

Example 1 — Basic Read

Beginner example for window.frameElement.

JavaScript
console.log(window.frameElement);
console.log(window.frameElement === null);
Try It Yourself

How It Works

  1. Step. Top-level tutorial pages return null.
  2. Step. Inside a same-origin iframe you get the element.

Example 2 — Practical Use

Beginner example for window.frameElement.

JavaScript
const embedded = window.frameElement !== null;
console.log(embedded ? "inside frame" : "top-level");
Try It Yourself

How It Works

  1. Step. A quick embed check for same-origin cases.

Example 3 — Check / Compare

Beginner example for window.frameElement.

JavaScript
console.log("frameElement" in window);
Try It Yourself

How It Works

  1. Step. The property exists even when its value is null.

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.

Browsers Environment
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 support
window.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.

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