欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-11-28 09:28:04
本文实例讲述了javascript实现定时页面跳转功能。分享给大家供大家参考,具体如下:

本文实例讲述了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相关内容感兴趣的读者可查看本站专题:《javascript时间与日期操作技巧总结》、《javascript切换特效与技巧总结》、《javascript查找算法技巧总结》、《javascript动画特效与技巧汇总》、《javascript错误与调试技巧总结》、《javascript数据结构与算法技巧总结》、《javascript遍历算法与技巧总结》及《javascript数学运算用法总结

希望本文所述对大家javascript程序设计有所帮助。