Ich führe eine Countdown-Uhr. Wenn der Countdown abgelaufen ist. Ich möchte die Seite einmal aktualisieren. Ich verwende location.reload, aber es lädt und lädt und lädt weiter. Wie kann ich diese Schleife unterbrechen?Wie stoppe ich JQuery location.reload Laden mehr als einmal?
<script type="text/javascript">
$('#clock').countdown('<?php echo $tickets_pageRecord['sales_start_date']; ?>')
.on('update.countdown', function(event) {
var format = '%H hr%!H %M min%!M %S sec%!S';
if(event.offset.totalDays > 0) {
format = '%-d day%!d ' + format;
}
if(event.offset.weeks > 0) {
format = '%-w week%!w ' + format;
}
$(this).html('Box Office opens in ');
$(this).append(event.strftime(format));
})
.on('finish.countdown', function(event) {
$(this).html('<h3>Click on shopping cart to buy tickets</h3>');
location.reload();
});
</script>
Verwenden Sie den lokalen Speicher, um eine Variable zum Speichern des Status festzulegen. –
localstorage ist nur die Option –