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

232
Vistas
Sending a variable from popup.js to content script

Is it possible for me to pass a variable from my popup.js and use it globally in my content script? I need to be able to pass a variable from the popup and use it in my content script as a variable. I've tried all sorts of answers but I'm still stuck.

Below is a code snippet where I would have to use the user input assigned to minNum:

if (checkPage() == true) {
        if (num <= minNum) {
            console.log('Leaving call.');
            leaveCall();
        }
    }

Below are my popup.js and popup.html file that just adds or reduces variable people:

people = 3;

document.addEventListener(
    'DOMContentLoaded',
    function () {
        var addButton = document.getElementById('add');
        var reduceButton = document.getElementById('reduce');

        addButton.addEventListener(
            'click',
            function () {
                people += 1;
                document.getElementById('minNum').innerHTML = people;
            },
            false
        );
        reduceButton.addEventListener(
            'click',
            function () {
                people -= 1;
                document.getElementById('minNum').innerHTML = people;
            },
            false
        );
    },
    false
);
<!DOCTYPE html>
<html>

<head>
  <title>Yeet Meet</title>
</head>

<body>
  <h1 id="minNum">3</h1>
  <button id="add">+</button>
  <button id="reduce">-</button>
  <script src="popup.js"></script>
</body>

</html>

I want to pass variable people to my content script so that I could assign it to minNum.

I apologize if this has already been answered and it probably just flew over my head but I can't seem to make anything work. Thank you for your help.

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