Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Message sent from contentScript.js not received by popup.js in Chrome Extension

I am developing a Chrome extension. I want to pass a message from the contentScript.js to my popup.js file. This should happen when the contentScript.js loads. From what I have read, I use " chrome.runtime.sendMessage" to do this. I am not sure how to actually receive it in the popup.js file. I have read that you need to use "chrome.runtime.onMessage.addListener", however it does not work.

contentScript.js

window.onload = function() {  
    var markup = document.documentElement.innerHTML;
    alert(markup);

    chrome.runtime.sendMessage({a:"b"});

    //This alert fires.
    alert("Content sent");
};

popup.js

    chrome.runtime.onMessage.addListener(
       function(request, sender, sendResponse) {
        //This alert never fires. 
        alert("Message Received!"); 
       }
   );

There are no errors received in the console, nor the extensions page. The message is either never sent, or is sent on not received. What am I missing?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!