第一个(毫秒级):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">
var duration=9900;
var endTime = new Date().getTime() + duration + 100;
function interval()
{
var n=(endTime-new Date().getTime())/1000;
if(n<0) return;
document.getElementById("timeout").innerHTML = n.toFixed(3);
setTimeout(interval, 10);
}
window.onload=function()
{
setTimeout("window.location.href='http://www.baidu.com'", duration);
interval();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>等待10秒</title>
</head>
<body>
<form id="form1" runat="server">
<div>
现在剩下 <span id="timeout">10.000</span> 秒后 将自动跳转 </div>
</form>
</body>
</html>

第二个:

<!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 runat="server">
<title>
等待10秒
</title>
<script type="text/javascript">
function run() {
var s = document.getElementById("dd");
if (s.innerHTML == 0) {
window.location.href = 'www.baidu.com';
return false;
}
s.innerHTML = s.innerHTML * 1 - 1;
}
window.setInterval("run();", 1000);
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
请等待<span id="dd">10</span>秒
</div>
</form>
</body>
</html>

第三个:

<html>

    <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>
counter
</title>
<script language="javascript" type="text/JavaScript">
function Counter(nMax, nInterval) {
this.maxTime = nMax;
this.interval = nInterval;
this.objId = "timer";
this.obj = null;
this.num = this.maxTime;
this.timer = null;
this.start = function() {
this.obj = document.getElementById(this.objId);
if (this.num > 0) setTimeout(this.run, this.interval * 1000);
};
this.run = function() {
if (myCounter.num > 0) {
myCounter.num--;
myCounter.obj.innerHTML = myCounter.num;
myCounter.timer = setTimeout(myCounter.run, myCounter.interval * 1000);
} else clearTimeout(myCounter.timer);
};
this.show = function() {
document.write("<span id=" + this.objId + ">" + this.num + "</span>");
this.obj = document.getElementById(this.objId);
//alert(this.obj.innerHTML);
}
}
</script>
</head> <body onload="myCounter.start();">
<script language="JavaScript" type="text/JavaScript">
var myCounter = new Counter(10, 1);
</script>
<p>
现在剩下
<script language="JavaScript" type="text/JavaScript">
myCounter.show();
</script>
秒钟!
</p>

js 倒计时(转)的更多相关文章

  1. js倒计时-倒计输入的时间

    计算指定时间到指定时间之间相差多少天.时.分.秒. 节日.活动.商城常用. 原理: 主要使用到时间戳,也就是从1970 年 1 月 1 日 到指定时间的毫秒数. 1. 求出毫秒差 :当两个时间直接进行 ...

  2. js 倒计时(可自定义时间)

    <html> <head> <title>js 倒计时</title> </head> <body> <div> & ...

  3. js倒计时显示

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>j ...

  4. Js倒计时程序

    Js倒计时程序 点击下载

  5. JS倒计时网页自动跳转代码

    <title>JS倒计时网页自动跳转代码</title> <script language="JavaScript" type="text/ ...

  6. JS倒计时 代码

    JS倒计时 代码 <div> <span id="KSD">3</span>天 <span id="KSH">1 ...

  7. js倒计时函数和(js禁用和恢复a标签的操作)

    <script type="text/javascript"> /*获取手机号*/ var start_time=60; function get_phone_nums ...

  8. js 倒计时跳转

    用js实现简单的倒计时结束页面跳转效果,主要用到setInterval()和clearInterval()方法,页面跳转使用window.location.href = " ".倒 ...

  9. 常见JS倒计时

    https://www.jb51.net/Special/356.htm  //JS倒计时  <button onclick="resetTime(60)">启动倒计时 ...

  10. 页面倒计时跳转页面效果,js倒计时效果

    页面倒计时跳转页面效果,js倒计时效果 >>>>>>>>>>>>>>>>>>>> ...

随机推荐

  1. snort使用

    http://jingyan.baidu.com/article/d8072ac45a626fec95cefd85.html 接上篇,如果编译安装snort并指定了prefix,那么须指定一个软链接, ...

  2. python psutil 模块

    一.获取系统性能信息 1 .CPU信息 User time,执行用户进程的时间百分比 System time,执行内核进程和中断的百分比 Wait IO,由于IO等待而使CPU处于idle(空闲)状态 ...

  3. Ext JS4 学习笔记之发送表单(Form)时也将表单下的表格(Grid)数据一同发送的方法

    Ext JS4 学习笔记之发送表单(Form)时也将表单下的表格(Grid)数据一同发送的方法 昨天在开发的时候遇到个小问题,就是如何将Grid的内容与Form一起发送到服务器端.默认情况下,表单(F ...

  4. 获取在线人数 CNZZ 和 51.la

    string Cookies = string.Empty; /// <summary> /// 获取在线人数 (51.la统计器) /// </summary> /// &l ...

  5. TextArea限制输入长度

    cs文件中添加文本框属性this.TextBox.Attributes.Add("MaxLength", "200"); $(document).ready(f ...

  6. IRedisClient 常用方法说明

    事实上,IRedisClient里面的很多方法,其实就是Redis的命令名.只要对Redis的命令熟悉一点就能够非常快速地理解和掌握这些方法,趁着现在对Redis不是特别了解,我也对着命令来了解一下这 ...

  7. 【Spring学习笔记-1】Myeclipse下Spring环境搭建

    *.hl_mark_KMSmartTagPinkImg{background-color:#ffaaff;}*.hl_mark_KMSmartTagBlueImg{background-color:# ...

  8. CentOS生产机器禁止ROOT远程SSH登录

    方法一 很多站长拥有linux主机,不管是虚拟机还是实体机,一般我们远程连接的时候,都是用的ssh(SecureShell建立在应用层和传输层基础上的安全协议). 它默认的端口22,默认使用root也 ...

  9. golang获取字符串长度需要注意的地方

    中文长度,直接贴代码 package main import ( "fmt" "unicode/utf8" ) func main() { aa := &quo ...

  10. C#如何判断我的程序已经有一个实例正在运行

    static class Program { private static Mutex mutex; /// <summary> /// 应用程序的主入口点. /// </summa ...