日期:2014-05-18 浏览次数:20545 次
<html>
<head>
<script>
window.onload = function(){
setInterval("a()", 1000);
}
function a(){
document.getElementById("label1").innerText -= 1;
if (document.getElementById("label1").innerText == 0)
window.location.href = "http://zhidao.baidu.com";
}
</script>
</head>
<body>
<span id="label1">
10
</span>
</body>
</html>
<html>
<title>倒计时跳转网页</title>
<head>
</head>
<body>
<script>
var cTime = 3;//这个变量是倒计时的秒数设置为10就是10秒
function TimeToJump()
{
window.setTimeout(‘TimeToJump()’,1000);//让程序每秒重复执行当前函数。
if(cTime > 0)//判断秒数如果为0
{ ShowTime.innerHTML=”倒计时”+cTime+”秒后跳转”;//显示倒计时时间
cTime–;//减少秒数
}
else{Jump_Click();//执行跳转的操作
}
}
function Jump_Click()
{
window.location = “http://baidu.com”;
}
TimeToJump()
</script>
<div id=”ShowTime”></div>
<input type=”button” name=”Jump” onClick=”Jump_Click();” value=”立即跳转”>
</body>
</html>
------解决方案--------------------
<html>
<head>
<script>
window.onload = function(){
setInterval("a()", 1000);
}
function a(){
document.getElementById("label1").firstChild.nodeValue -= 1;
if (document.getElementById("label1").firstChild.nodeValue == 0)
window.location.href = "http://zhidao.baidu.com";
}
</script>
</head>
<body>
<span id="label1">
10
</span>
</body>
</html>