Example 1 — Basic Read
Beginner example for window.parent.
console.log(window.parent === window);
console.log(typeof window.parent); How It Works
- Step. Top-level pages are their own parent.
- Step. parent is still a Window object.

window.parent is the parent browsing context. On a top-level page with no iframe, parent === window.
Read window.parent with no parentheses.
window.parent; | Call | What it does |
|---|---|
window.parent | The parent window; equals window on top-level pages. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.parent | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | The parent window; equals window on top-level pages. |
Beginner example for window.parent.
console.log(window.parent === window);
console.log(typeof window.parent); Beginner example for window.parent.
const isTopLevel = window.parent === window;
console.log(isTopLevel ? "top-level" : "framed"); Beginner example for window.parent.
console.log(window.parent.document === document); window.parent is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful