当前位置: 移动技术网 > IT编程>开发语言>JavaScript > JavaScript实现定时页面跳转功能示例

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

2019年03月25日  | 移动技术网IT编程  | 我要评论

本文实例讲述了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程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网