<!DOCTYPE html>
<html>
<head>
<title>js22.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<!-- 设定跳转的时间 定时器的使用 -->
<script type="text/javascript">
var timerId;
function loadPage(){
timerId = setInterval('countdown()',1000);
}
</script>
</head>
<body onload = "loadPage();">
<script type="text/javascript">
var sec = 3;;
function countdown(){
if(sec>0)
document.getElementById("num").innerHTML = sec--;
else{
clearInterval(timerId);
location.href = "http://www.baidu.com";
}
}
</script>
3秒钟后跳转
<font id = "num" size = 7 color = "blue">3</font>
</body>
</html>
说明:onload会在图片或者页面加载完成后立即发生。