Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda