你变量名和函数名是相同的,执行startTime的时候,把函数改成时间了,所以第二次调用就没了...
<!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=gb2312" />
<title>无标题文档 </title>
</head> <body>
<script language="javascript">
var this_ClearTimeOut;
var startTime;
var EndTime;
var this_timeOut = 0;
var timeout;
var this_ClearTimeOut;
function startTime_()
{
alert("start time!");
startTime = new Date();
if(this_timeOut > 0){
clearInterval(this_timeOut);
}
this_timeOut=setInterval('GetRTime()',1000);
} function GetRTime(){ EndTime=startTime.getTime()+6*60*1000;
var NowTime = new Date();
var nMS =EndTime - NowTime.getTime();
//var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
//var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60));
var nS=Math.floor(nMS/1000) % 60;
//document.getElementById("RemainD").innerHTML=nD;
// document.getElementById("RemainH").innerHTML=nH;
//alert("aaaaaaaaaaaaa"+nM);
document.getElementById("RemainM").innerHTML=nM;
document.getElementById("RemainS").innerHTML=nS;
if(nMS>1*59*1000&&nMS <=1*60*1000)
{
alert("还有最后一分钟!");
}
//setInterval('GetRTime()',1000);
//alert("aaaaa"+nMS); }
function SendOption(iAliveSeconds)
{
alert("aaaaaa");
this_ClearTimeOut=setTimeout('startTime_()',1000);
} function EndTimeOut(){ alert("Time out")
clearTimeout(this_ClearTimeOut);
clearInterval(this_timeOut);
document.getElementById("RemainM").innerHTML="XX";
document.getElementById("RemainS").innerHTML="XX";
startTime="";
EndTime="";
} </script>
<input name="start" value="start" type="button" onclick="SendOption()"/>
<input name="end" type="button" value="end" onclick="EndTimeOut()"/>
<span id="CountMsg">倒计时: <strong id="RemainM">XX </strong>分 <strong id="RemainS">XX </strong>秒 </span>
</body>
</html>
<!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=gb2312" />
<title>无标题文档 </title>
</head> <body>
<script language="javascript">
var this_ClearTimeOut;
var startTime;
var EndTime;
var this_timeOut = 0;
var timeout;
var this_ClearTimeOut;
function startTime_()
{
alert("start time!");
startTime = new Date();
if(this_timeOut > 0){
clearInterval(this_timeOut);
}
this_timeOut=setInterval('GetRTime()',1000);
} function GetRTime(){ EndTime=startTime.getTime()+6*60*1000;
var NowTime = new Date();
var nMS =EndTime - NowTime.getTime();
//var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
//var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60));
var nS=Math.floor(nMS/1000) % 60;
//document.getElementById("RemainD").innerHTML=nD;
// document.getElementById("RemainH").innerHTML=nH;
//alert("aaaaaaaaaaaaa"+nM);
document.getElementById("RemainM").innerHTML=nM;
document.getElementById("RemainS").innerHTML=nS;
if(nMS>1*59*1000&&nMS <=1*60*1000)
{
alert("还有最后一分钟!");
}
//setInterval('GetRTime()',1000);
//alert("aaaaa"+nMS); }
function SendOption(iAliveSeconds)
{
alert("aaaaaa");
this_ClearTimeOut=setTimeout('startTime_()',1000);
} function EndTimeOut(){ alert("Time out")
clearTimeout(this_ClearTimeOut);
clearInterval(this_timeOut);
document.getElementById("RemainM").innerHTML="XX";
document.getElementById("RemainS").innerHTML="XX";
startTime="";
EndTime="";
} </script>
<input name="start" value="start" type="button" onclick="SendOption()"/>
<input name="end" type="button" value="end" onclick="EndTimeOut()"/>
<span id="CountMsg">倒计时: <strong id="RemainM">XX </strong>分 <strong id="RemainS">XX </strong>秒 </span>
</body>
</html>
原来如此简单
实在太谢谢了~~,开始还真没发现