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

  • Home
  • SEARCH
  • 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 7542523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:11:22+00:00 2026-05-30T08:11:22+00:00

I am creating a Chrome Extension that upon clicking the extension icon will present

  • 0

I am creating a Chrome Extension that upon clicking the extension icon will present the user with a button, clicking that button will open a new tab which will display a parameter passed to it from the original page. The strange thing is that this will work if I debug it (i.e. right click the extension icon and click “Inspect popup”), but it will just show a blank page upon clicking the button if I’m not debugging.

manifest.json

{  
    "name": "test name",  
    "version" : "0.1",  
    "description": "test description",  
    "browser_action":  
    {  
        "default_icon": "icon_128.png",  
        "popup": "test.html"  
    },  
    "permissions": [  
        "tabs", "http://*/*", "https://*/*"  
    ]  
}  

test.html

<HTML>  
<BODY>  
<script type="text/javascript">  
var currentWindowID = -1;  

window.onload = function(e){   
    chrome.windows.getCurrent(function(w)  
    {  
        currentWindowID = w.id;  
    });  
}  

function openNextPage(){  
    console.log("in openNextPage");  
    chrome.tabs.create(  
        {url: "test2.html"},   
        function(tab)  
        {             
            chrome.tabs.sendRequest(tab.id, {someParam: currentWindowID});  
        }  
    );  
    console.log("exiting openNextPage");  
}  
</script>  
<input type="button" value="Show next page" onClick="openNextPage()">  
</BODY>  
</HTML>  

test2.html

<HTML>  
<script type="text/javascript">  
    chrome.extension.onRequest.addListener(function(request)  
    {  
        document.write("<h1>test</h1>");  
        document.write("<h2>value=" + request.someParam + "</h2>");  
    });  
</script>  
</HTML>  
  • 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-30T08:11:24+00:00Added an answer on May 30, 2026 at 8:11 am

    The browser will activate the new tab when it is created, and your popup will be closed. Therefore, the callback is never called from chrome.tabs.create. The background page is a more proper place for such code.

    test.html

    <HTML>  
    <BODY>  
    <script type="text/javascript">  
    var currentWindowID = -1;  
    
    window.onload = function(e){   
      chrome.windows.getCurrent(function(w)  
      {  
          currentWindowID = w.id;  
      });  
    }  
    
    function openNextPage() {  
      var bg = chrome.extension.getBackgroundPage();
      bg.openNextPage(currentWindowID);
    }  
    </script>  
    <input type="button" value="Show next page" onClick="openNextPage()">  
    </BODY>  
    </HTML>
    

    background.html

    <HTML>  
    <BODY>  
    <script type="text/javascript">  
    function openNextPage(currentWindowID) {  
      console.log("in openNextPage");  
      chrome.tabs.create(  
        {url: "test2.html"},   
        function(tab)  
        {             
            chrome.tabs.sendRequest(tab.id, {someParam: currentWindowID})
        }  
      );  
      console.log("exiting openNextPage");  
    }
    </script>  
    </BODY>  
    </HTML>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Chrome extension which will send the URL of every page
I am creating an google-chrome-extension which has html notifications. There will be a close
I'm creating a Chrome extension that uses key bindings (i.e. will use javascript keydown
I am new to the world of creating Chrome extensions. My extension will not
While creating a Google Chrome extension, I have code that must remain in a
I am creating an extension that will launch an external script based on highlighted
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
I'm opening a new window by clicking on the extension button near the search
I am creating a Chrome extension which has a Javascript modifying Facebook page layout,
I'm creating a Chrome extension that appends a script tag to a page, and

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.