Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3843652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:58:07+00:00 2026-05-19T15:58:07+00:00

In my extension, I’m trying to determine whether a new tab was created as

  • 0

In my extension, I’m trying to determine whether a new tab was created as a popup by another tab and if so, which tab.

I thought I would be able to use window.opener from a content script to help figure this out. But it looks like window.opener doesn’t work correctly in content scripts.

When I create a tab manually, it’s window.opener is null as expected.

When a tab is created as a popup by another tab, its window.opener is undefined. I can infer from this that the tab was created as a popup, but I can’t use it to figure out which tab created the new one.

Is this a known issue, and does anybody know of any workarounds?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:58:07+00:00Added an answer on May 19, 2026 at 3:58 pm

    I didn’t look closely into this problem, but I think I can point you in the right direction. Content script can’t access a variable from a parent window because it is sandboxed. A workaround would be to run your code directly on a page, to do this you need to inject your script inside a script tag:

    Your content script would look like this:

    function injectJs(link) {
            var scr = document.createElement("script");
            scr.type="text/javascript";
            scr.src=link;
            (document.head || document.body || document.documentElement).appendChild(scr);
    }
    
    injectJs(chrome.extension.getURL("inject.js"));
    

    Now you can run your code without sandbox restrictions as if it was right on the page:

    inject.js:

    alert(window.opener);
    

    I assume you would like to now pass this information back to a background page, which is another challenge as you can’t use Chrome API. Good news is that content script can access DOM and listen to DOM events, so you can use them to pass information to a content script which would send it to a background page. I am pretty sure you should be able to register a custom DOM event and have your content script listening to it (haven’t tried this part myself).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created an extension method over IQueryable type, which takes a subset of entities
My extension opens a new safari window: safari.application.openBrowserWindow().activeTab.url = safari.extension.baseURI + popup.html And I
an extension of my last question, getDate with Jquery Datepicker , I am trying
ReSharper extension of VS suggest me to use PascalCase in below property. public Color
I am making an extension method library to use in windows form applications. One
Why Extension methods do not use implicit conversions but static methods do? Can anybody
Does PHP have an extension that permits to use a tar.gz like a folder?
I want use html5's new tag to play a wav file (currently only supported
Is there any extension or widget like the above image which i saw in
Using extension syntax I'm trying to create a left-join using LINQ on two lists

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.