JavaScript实现倒计时跳转页面功能【实用】
这里给大家提供一个好用的JS写的倒计时页面,就像一些网站上点提交后出现的倒计时页面类似。
页面代码简单,直接拷贝就能运行,页面可以自己美化下。
<!--这里定义倒计时开始数值-->
<spanid="totalSecond">5</span>
<!--定义js变量及方法-->
<scriptlanguage="javascript"type="text/javascript">
varsecond=document.getElementById('totalSecond').textContent;
if(navigator.appName.indexOf("Explorer")>-1)
{
second=document.getElementById('totalSecond').innerText;
}else
{
second=document.getElementById('totalSecond').textContent;
}
setInterval("redirect()",1000);
functionredirect()
{
if(second<0)
{
<!--定义倒计时后跳转页面-->
location.href='default.aspx';
}else
{
if(navigator.appName.indexOf("Explorer")>-1)
{
document.getElementById('totalSecond').innerText=second--;
}else
{
document.getElementById('totalSecond').textContent=second--;
}
}
}
</script>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持毛票票!