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

209
Views
Chrome extension message sending from background to content issue

I'm trying to send the current active URL from any updated tab to it's respective content script with the code below. I'm having trouble confirming receipt of any message in the content script/page console. However, the console.log's in background.js are showing up..

I've also noticed that sometimes the changeInfo.url will send as undefined? If I remove the if (changeInfo.url) { conditional from background.js, the background script will log out 2-3 times per page-load, with the latter instances logging changeInfo.url as undefined.

I'm new to Chrome extension development, what am I missing? Thanks!

background.js :

chrome.tabs.onUpdated.addListener( 
    function(tabId, changeInfo, tab) {
    if (changeInfo.url) {
        console.log(tabId, changeInfo.url, tab);
        chrome.tabs.sendMessage( tabId, {
            message: 'hello!',
            url: changeInfo.url
        })
    }
});

content.js :

chrome.runtime.onMessage.addListener(
    function (request, sender, sendResponse) {
        console.log("this is the url:" + request.url)
    }
)
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!