javascript倒计时
代码
<script language="javascript">
var i=5;
<!--
function clock(){
//document.title="本窗口将在"+i+"秒后自动关闭!";
document.getElementById("s").innerHTML = i;
if(i>0)
setTimeout("clock();",1000);
else
//self.close();
window.history.back(-1); // 跳转到其他页面
i--;
}
//-->
</script>
var i=5;
<!--
function clock(){
//document.title="本窗口将在"+i+"秒后自动关闭!";
document.getElementById("s").innerHTML = i;
if(i>0)
setTimeout("clock();",1000);
else
//self.close();
window.history.back(-1); // 跳转到其他页面
i--;
}
//-->
</script>
代码
<!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=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var i=5;
function clock(){
document.getElementById("test").innerHTML=i;
if(i>0){
setTimeout("clock()",1000);
}
else{
location.href=location.href; //5秒后刷新
}
i--;
}
</script>
</head>
<body onload="clock()">
<div id="test"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var i=5;
function clock(){
document.getElementById("test").innerHTML=i;
if(i>0){
setTimeout("clock()",1000);
}
else{
location.href=location.href; //5秒后刷新
}
i--;
}
</script>
</head>
<body onload="clock()">
<div id="test"></div>
</body>
</html>