JavaScript

超轻量级php框架startmvc

JavaScript实现定时页面跳转功能示例

更新时间:2020-04-23 01:35:01 作者:startmvc
本文实例讲述了JavaScript实现定时页面跳转功能。分享给大家供大家参考,具体如下:<!DOC

本文实例讲述了JavaScript实现定时页面跳转功能。分享给大家供大家参考,具体如下:


<!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>Test</title>
<script type="text/javascript" language="javascript" >
<!--
var time = 8; //时间,秒
function Redirect(){
window.location = "//www.jb51.net/";
}
var i = 0;
function dis(){
document.all.s.innerHTML = "还剩" + (time - i) + "秒";
i++;
}
timer=setInterval('dis()', 1000);//显示时间
timer=setTimeout('Redirect()',time * 1000); //跳转
//-->
</script>
</head>
<body>
<span id="s"></span>
</body>
</html>

JavaScript 定时 页面跳转