内置函数setInterval的用法

来源:互联网 发布:公司做账用什么软件 编辑:程序博客网 时间:2024/05/17 22:07

<!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=gb2312" />
<title>setInterval测试</title>
<style type="text/css">
<!--
.STYLE1 {
color: #0000FF;
font-size: 36px;
font-weight: bold;
}
-->
</style>
</head>

<body>
恭喜你,注册成功,<span id="num" class="STYLE1"></span>秒后跳转到百度首页!
</body>
</html>
<script language="javascript" type="text/javascript">
var i = 5;

function fun()
{
if(i != 0)
{
   document.getElementById("num").innerHTML = i;
   i--;
}
else
{
   window.location.href = "http://www.baidu.com/";
}
}

setInterval("fun()",1000);
</script>

原创粉丝点击