刷新页面,js写的倒计时怎么写才不重新加载? 5
这是我的js倒计时代码:<body><divid="timer"><spanid="endtime">10</span><br/><inputid="lingqu"typ...
这是我的js倒计时代码:
<body>
<div id="timer"><span id="endtime">10</span><br/><input id="lingqu" type="button" value="领取奖励"/></div>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null)
{
var iTime = document.getElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime()
{
var iDay,iHour,iMinute,iSecond;
var sDay="",sHour="",sMinute="",sSecond="",sTime="";
if (iTime >= 0)
{
Account = setTimeout("RemainTime()",1000);
iHour = parseInt((iTime/3600)%24);
if (iHour > 0){
sHour = iHour + ":";
}else if(iHour == 0){
sHour = "00:";
}
iMinute = parseInt((iTime/60)%60);
if (iMinute > 0){
sMinute = iMinute + ":";
}else if(iMinute == 0){
sMinute = "00:";
}
iSecond = parseInt(iTime%60);
if (iSecond >= 0){
sSecond = iSecond ;
}
if ((sDay=="")&&(sHour=="")){
sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
}
else
{
sTime=sDay+sHour+sMinute+sSecond;
}
iTime=iTime-1;
}
else
{
sTime="<span style='color:red'>倒计时结束!</span>";
iTime=10;
Account = setTimeout("RemainTime()",1000);
}
document.getElementById(CID).innerHTML = sTime;
}
</script>
</body>
希望高手指点一下,本人有点笨,最好具体一点,呵呵。 展开
<body>
<div id="timer"><span id="endtime">10</span><br/><input id="lingqu" type="button" value="领取奖励"/></div>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null)
{
var iTime = document.getElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime()
{
var iDay,iHour,iMinute,iSecond;
var sDay="",sHour="",sMinute="",sSecond="",sTime="";
if (iTime >= 0)
{
Account = setTimeout("RemainTime()",1000);
iHour = parseInt((iTime/3600)%24);
if (iHour > 0){
sHour = iHour + ":";
}else if(iHour == 0){
sHour = "00:";
}
iMinute = parseInt((iTime/60)%60);
if (iMinute > 0){
sMinute = iMinute + ":";
}else if(iMinute == 0){
sMinute = "00:";
}
iSecond = parseInt(iTime%60);
if (iSecond >= 0){
sSecond = iSecond ;
}
if ((sDay=="")&&(sHour=="")){
sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
}
else
{
sTime=sDay+sHour+sMinute+sSecond;
}
iTime=iTime-1;
}
else
{
sTime="<span style='color:red'>倒计时结束!</span>";
iTime=10;
Account = setTimeout("RemainTime()",1000);
}
document.getElementById(CID).innerHTML = sTime;
}
</script>
</body>
希望高手指点一下,本人有点笨,最好具体一点,呵呵。 展开
1个回答
2011-05-28
展开全部
骗人的网页,没人愿意助纣为虐!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
网易云信
2023-12-06 广告
2023-12-06 广告
很高兴能回答您的问题。以下是一段针对“一对一消息组件”的描述,字数在200字左右:该组件支持用户之间的私密交流,让沟通更加直接和高效。通过它,您可以向特定对象发送消息,并实时查看消息状态,包括对方是否已读或未读。同时,该组件还支持富文本消息...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询