【求助这里高手帮忙】关于倒计时代码问题!(其他地方高手解决不了)
我在很多地方包括百度求救都得不到有效的办法。我这个倒计时代码在本地测试刷新不受影响不会重新倒计时。但关闭网页重新打开又重新开始倒计时
问高手说要传到服务器空间上。但我传到我网站空间上,不管刷新还是关闭网页再打开,倒计时它都会重新开始计时。真郁闷啊!
我的代码如下:
<SCRIPT LANGUAGE="JavaScript">
<!--
var flag = true;
var maxtime;
if(window.name==''){
maxtime = 59*60;
}else{
maxtime = window.name;
}
function reset(){
if(flag == true){
maxtime = 59*60;
timer = setInterval("CountDown()",1000);
}
}
function CountDown(){
flag = false;
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = 距离XXX还有"+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML = msg;
if(maxtime == 5*60) alert('注意,还有5分钟!');
--maxtime;
window.name = maxtime;
}
else{
flag = true;
clearInterval(timer);
alert("时间到!");
}
}
timer = setInterval("CountDown()",1000);
//-->
</SCRIPT>
<html>
<body>
<div id="timer" style="color:red"></div>
<br>
<input type="button" value="重新倒计时" onclick="reset()">
</body>
</html>
<!--
var flag = true;
var maxtime;
if(window.name==''){
maxtime = 59*60;
}else{
maxtime = window.name;
}
function reset(){
if(flag == true){
maxtime = 59*60;
timer = setInterval("CountDown()",1000);
}
}
function CountDown(){
flag = false;
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = 距离XXX还有"+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML = msg;
if(maxtime == 5*60) alert('注意,还有5分钟!');
--maxtime;
window.name = maxtime;
}
else{
flag = true;
clearInterval(timer);
alert("时间到!");
}
}
timer = setInterval("CountDown()",1000);
//-->
</SCRIPT>
<html>
<body>
<div id="timer" style="color:red"></div>
<br>
<input type="button" value="重新倒计时" onclick="reset()">
</body>
</html>