-
Notifications
You must be signed in to change notification settings - Fork 0
/
prueba.html
59 lines (50 loc) · 1.44 KB
/
prueba.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temporizador y reinicio de página</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
#timer {
font-size: 24px;
color: #333;
}
</style>
</head>
<body>
<div id="timer">10</div>
<script>
// Función que reinicia la página
function reiniciarPagina() {
location.reload(true);
}
// Función del temporizador
function iniciarTemporizador(segundos) {
let tiempoRestante = segundos;
const timerElemento = document.getElementById('timer');
function actualizarTemporizador() {
timerElemento.textContent = tiempoRestante;
if (tiempoRestante === 0) {
reiniciarPagina();
} else {
tiempoRestante--;
setTimeout(actualizarTemporizador, 1000);
}
}
actualizarTemporizador();
}
// Iniciar temporizador con 10 segundos al cargar la página
document.addEventListener('DOMContentLoaded', function () {
iniciarTemporizador(10);
});
</script>
</body>
</html>