를 재설정에서 타이머 ..방지 나는 시간이 문제는 페이지가 다시로드 할 때 타이머가 처음부터 다시 시작한다는 것입니다 0</p> <p>에 도달하면 프로그램을 종료 카운트 다운 타이머 스크립트를 만들고있어
타이머가 재설정되지 않도록 할 수있는 방법이 있습니까?
// set the date we're counting down to
var target_date = new Date().getTime();
var delay=100;
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdown = document.getElementById("countdown");
// update the tag with id "countdown" every 1 second
setInterval(function() {
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (current_date - target_date)/1000;
var a=(delay-seconds_left);
// do some time calculations
minutes = parseInt(a/60);
seconds = parseInt(a % 60);
var progress = a/delay*100;
// format countdown string + set tag value
countdown.innerHTML = '<div Class=outer style="font-size:20px;width:'+progress+'%">'+minutes + "m: " + seconds + "s" + '</div>';
if(a <= 0)
{
window.open("a.html")
self.close();
//var wind = window.open("a.html");
}
}, 1000);
* "타이머가 다시 설정되는 것을 방지 할 수있는 방법이 있습니까?"* * "새로 고침 방지"*가 제안하는 제목과 다른 질문입니다. –