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 8283481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:44:57+00:00 2026-06-08T10:44:57+00:00

In a Google Chrome extension I want to pass messages between a content script

  • 0

In a Google Chrome extension I want to pass messages between a content script and a popup page. I also want a function in the content script to be fired when a signal to do this is sent by the popup page to the content script.

The section in Google Chrome Extensions developer docs for messages, states that messages can be passed “from your content script to an extension page, or vice versa” (quoted from http://code.google.com/chrome/extensions/messaging.html )

Does this mean that I can send/receive messages between the content script and the popup page? Because the usage I have seen is for communication between background page and content script.

Or do I have to set up a 3 – way message passing route– viz.
content script <–> background page <–> popup page. And if this is the case, how do I set up messaging between background page <–> popup page?

And how do I fire a function in the content script, after sending signal to content script from the popup page? Does this also require background script to be present?

  • 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-06-08T10:44:58+00:00Added an answer on June 8, 2026 at 10:44 am

    Content scripts can only send a message to the background page. If you want to send a message from a content script to a popup, you have to:

    1. Send the message from the Content script to the background page.

      chrome.runtime.sendMessage( ...message... , function() { /*response*/ });
      
    2. Receive the message at the background.

      chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { ... });
      
    3. Pass the message to the popup. To get a reference to the global window object of the popup, use chrome.extension.getViews. Note: Unlike most of the other chrome APIs, this method is synchronous:

      var popupWindows = chrome.extension.getViews({type:'popup'});
      if (popupWindows.length) { // A popup has been found
          // details is the object from the onMessage event (see 2)
          popupWindows[0].whatever(message, sendResponse);
      }
      
    4. In the popup, define the whatever method.

      function whatever(message, sendResponse) {
          // Do something, for example, sending the message back
          sendResponse(message);
      }
      
    5. When sendResponse (4) is called, details.sendResponse (see 3) is called. This, in turn, calls function() { /*response*/ } from 1.

    Note: chrome.runtime.sendMessage/onMessage is only supported in Chrome 26+. Use chrome.extension.sendMessage if you want to support older browsers as well.

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

Sidebar

Related Questions

I want to save content of page in mongodb using google chrome extension. What
In my Google Chrome Extension, I have a Content Script (content.js) and a Background
I'm writing a Google Chrome extension which manipulates the current page (basically adds a
I want to write an extension for Google chrome that detects snippets of source
In a Google Chrome extension, I want to process a custom string in the
I'm writing a google chrome extension that uses chrome.pageCapture.saveAsMHTML(object details, function callback) function callback
I am trying to write an extension to google chrome and I want to
I'm developing a Google Chrome extension and I want to retrieve Google+ notifications count
So I wrote a Google Chrome extension. All I want to do is provide
I want to write a Google Chrome Extension that can take information from a

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.