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
| <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// Fonction pour rafraîchir la page
function refreshPage() {
location.reload();
}
// Temps jusqu'à minuit
const now = new Date();
let millisTillMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0, 0) - now;
if (millisTillMidnight < 0) {
millisTillMidnight += 86400000; // il est après minuit, attendre jusqu'au prochain jour
}
// Planifie le rafraîchissement de la page à minuit
setTimeout(function() {
setInterval(refreshPage, 86400000); // 86400000 millisecondes = 24 heures
}, millisTillMidnight);
</script>
</body>
</html> |
Partager