js页面打开倒计时

<!--这里定义倒计时开始数值-->

<span id="totalSecond">5</span>

 <!--定义js变量及方法-->

<script language="javascript" type="text/javascript">
var second = document.getElementById('totalSecond').textContent;

if (navigator.appName.indexOf("Explorer") > -1)
{
second = document.getElementById('totalSecond').innerText;
} else
{
second = document.getElementById('totalSecond').textContent;
}


setInterval("redirect()", 1000);
function redirect()
{
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>

原文地址:https://www.cnblogs.com/songqiaoli/p/2572104.html