-1
내 타이머는 아무 것도 표시하지 않습니다. insertBefore 함수와 관련이 있다고 생각하지만 확실하지 않습니다. 내 스팬에 숫자가 표시되지 않는 이유에 대한 아이디어가 있습니까?자바 스크립트 타이머 문제
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function timeMsg()
{
var t=setTimeout("displayMsg()",5000);
}
function displayMsg()
{
document.getElementById("timeoutmsg").style.display = 'block';
}
COUNTER_START = 60
function tick() {
if (document.getElementById ('counter').firstChild.data > 0) {
document.getElementById ('counter').firstChild.data = document.getElementById ('counter').firstChild.data - 1
setTimeout ('tick()', 1000)
} else {
document.getElementById ('counter').firstChild.data = 'done'
}
}
if (document.getElementById) onload = function() {
var t = document.createTextNode (COUNTER_START)
var p = document.createElement ('P')
p.appendChild (t)
p.setAttribute ('id', 'counter')
var body = document.getElementsByTagName ('timer')[0]
var firstChild = body.getElementsByTagName ('*')[0]
body.insertBefore (p, firstChild)
tick()
}
</script>
</head>
<body>
<div id="timeoutmsg" style="border: solid 2px black; background-color: #69F; width: 300px; height: 100px; text-align: center; position: absolute; display: ; left: 40%; top: 40%; z-index: 1;" >Your Session will expire in <span id="timer"></span> Click Here to Contine or you will be logged out.</div>
</body>
</html>