<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=EUC-KR" http-equiv="content-type">
<title>TEST</title>
</head>
<body>
<div>남은시간:</div>
<div id="timer_msg"></div>
</body>
</html>
<script language="javascript">
<!--
/* lifetime을 수정하여 최초 남은시간을 정의 */
var lifetime = 60;
var hour, min, sec;
/* 초단위 시간을 시/분/초로 분리하여 계산 */
function calc_time() {
hour = Math.floor(lifetime / 3600);
min = Math.floor(lifetime / 60 - (hour * 60));
sec = Math.floor(lifetime % 60);
if (hour < 10) hour = "0" + hour;
if (min < 10) min = "0" + min;
if (sec < 10) sec = "0" + sec;
}
/* 시간 출력 */
function print_timer() {
calc_time();
document.getElementById('timer_msg').innerHTML = hour + ":" + min + ":" + sec;
}
/* 1초마다 호출되어 처리되는 콜백함수 */
function count() {
lifetime--;
if (lifetime <= 0) {
clearInterval(timer);
self.close();
lifetime = 0;
}
print_timer();
}
print_timer();
timer = setInterval("count()", 1000);
//-->
</script>