JavaScript Window opener Property

Definition
window.opener is the window that opened this one with window.open(), or null when the user opened the tab normally.
Syntax
Read window.opener with no parentheses.
| Call | What it does |
|---|
window.opener | The window that called open(), or null. |
Window property in browsers. No import required.
Parameters
| Parameter | Description |
|---|
| window.opener | Read-only or assignable depending on the property. No function arguments. |
Return Value
| Return Value | Description |
|---|
| * | The window that called open(), or null. |
JavaScript Examples
Example 1 — Basic Read
Beginner example for window.opener.
console.log(window.opener === null || typeof window.opener === "object");
console.log("opener" in window);
How It Works
- Step. Typical tabs have opener null.
- Step. The property still exists.
Example 2 — Practical Use
Beginner example for window.opener.
if (window.opener) {
console.log("Opened by another window");
} else {
console.log("No opener");
}
How It Works
- Step. Branch on truthiness.
- Step. Most tutorial tabs print No opener.
Compatibility
Browser & Runtime Support
window.opener is a standard Window property in browsers.
✓ Browser Window API
window.opener
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.opener Excellent
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Frequently Asked Questions
A reference to the window that opened this one, or null.
When this page was opened with window.open() or a target without noopener.
It can be. Use rel="noopener" on untrusted links so new pages do not get your window.
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