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

117
Vistas
Stopwatch chrome extension to work after clicking out of popup.html

i've run into a problem that after i click out of my chrome extension popup it stops working. Its simple stopwatch which i want to still count the time after clicking out of window to do something in browser, i know that i have to execute the script somehow in the background.js but i just don't know how to so if anyone could help me with that issue and explain it to me i would be very greatful :) This is my popup.js file with working script.

var hours = 00;
var minutes = 00;
var seconds = 00;
var tens = 000;
var appendTens = document.getElementById("tens");
var appendSeconds = document.getElementById("seconds");
var appendMinutes = document.getElementById("minutes");
var appendHours = document.getElementById("hours");
var buttonStart = document.getElementById("start");
var buttonStop = document.getElementById("stop");
var buttonReset = document.getElementById("reset");
var interval;


function startTimer(){
    tens++;

    if (tens<9){
        appendTens.innerHTML = "0" + tens;
    }
    if (tens>9){
        appendTens.innerHTML = tens;
    }
    if (tens>99){
        seconds++;
        appendSeconds.innerHTML = "0" + seconds;
        tens = 0;
        appendTens.innerHTML = "0" + 0;
    }
    if (seconds>9){
        appendSeconds.innerHTML = seconds;
    }
    if (seconds>59){
        minutes++;
        appendMinutes.innerHTML = "0" + minutes;
        seconds = 0;
        appendSeconds.innerHTML = "0" + 0;
    }
    if (minutes>9){
    appendMinutes.innerHTML = minutes;
    }
    if (minutes>59){
        hours++;
        appendHours.innerHTML = "0" + hours;
        minutes = 0;
        appendMinutes.innerHTML = "0" + 0;
    }
    if (hours>9){
        appendHours.innerHTML = hours;
    }
}

buttonStart.onclick = function(){
    if(interval) {
        clearInterval(interval)
    }   
    interval = setInterval(startTimer, 10);
}

buttonStop.onclick = function(){
    clearInterval(interval);
}

buttonReset.onclick = function(){
    clearInterval(interval);
    tens = "00";
    seconds = "00";
    minutes = "00";
    hours = "00";
    appendTens.innerHTML = tens;
    appendSeconds.innerHTML = seconds;
    appendMinutes.innerHTML = minutes;
    appendHours.innerHTML = hours;
}
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