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

162
Vistas
Chrome extension issue with popup.js

I am working on a chrome extension, I have the following code in my popup.js which works correctly if the background page finishes loading, however, if I try to open the extension before the page finishes loading there is a JS error and nothing get executed;

There error I get in the extension report is: Uncaught TypeError: Cannot read properties of undefined (reading 'query') I have tried a few typeOf == undefined and add a delay until it loads but with not success.

    function initHome()
    {

        try {



            chrome.tabs.query({ 
            //This method output active URL 
                "active": true,
                "currentWindow": true,
                "status": "complete",
                "windowType": "normal"
            }, function (tabs) {
                for (tab in tabs) {
              
                    if(tabs[tab].active == true)
                    {

                        var  newUrl = new URL(tabs[tab].url);
                        var currentTab = tabs[0];
                         currentDomain = newUrl.hostname.replace('www.','');
                       
                        $('#header_domain').html(currentDomain);
                        
                        if(currentDomain.indexOf('google.') == -1 && currentDomain.indexOf('chrome') == -1)
                            process_home(currentDomain);

                       
                    }
          
                }
            });     


            } catch (error) {
              console.error(error);

            }

    }

    initHome();
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