zoukankan      html  css  js  c++  java
  • javascript sleep pause 实现

    参考地址:http://edu.codepub.com/2010/0908/25776.php

    <!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>无标题文档</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <style type="text/css">
    .center
    {
    width
    :960px;
    margin
    :0 auto;
    border
    :1px solid #333;
    background-color
    :#ccc;
    }
    </style>

    <script src="jquery-1.4.4.min.js" language="javascript" type="text/javascript">
    </script>
    <script type="text/javascript">
    function load()
    {
    alert(
    "test");
    }

    function Pause(obj,iMinSecond)
    {
    if (window.eventList==null) window.eventList=new Array();
    var ind=-1;
    for (var i=0;i<window.eventList.length;i++)
    {
    if (window.eventList[i]==null)
    {
    window.eventList[i]
    =obj;
    ind
    =i;
    break;
    }
    }

    if (ind==-1)
    {
    ind
    =window.eventList.length;
    window.eventList[ind]
    =obj;
    }
    setTimeout(
    "GoOn(" + ind + ")",iMinSecond);
    }
    /*
    该函数把要暂停的函数放到数组window.eventList里,同时通过setTimeout来调用继续函数。
    继续函数如下:
    */
    function GoOn(ind)
    {
    var obj=window.eventList[ind];
    window.eventList[ind]
    =null;
    if (obj.NextStep) obj.NextStep();
    else obj();
    }
    /*
    该函数调用被暂停的函数的NextStep方法,如果没有这个方法则重新调用该函数。
    函数编写完毕,我们可以作如下册是:
    */
    function Test()
    {
    alert(
    "hellow");
    Pause(
    this,5000);//调用暂停函数
    this.NextStep=function()
    {
    alert(
    "NextStep");
    }
    }
    </script>
    </head>

    <body onload="Test()">

    <div class="center">test</div>
    </body>
    </html>

      

  • 相关阅读:
    C winpcap 网络抓包 并获取IP TCP 协议的相关信息
    python基础
    k8s部署测试实例
    node节点的部署
    k8s集群之master节点部署
    k8s集群之Docker安装镜像加速器配置与k8s容器网络
    k8s集群部署之环境介绍与etcd数据库集群部署
    docker存储管理
    docker 镜像仓库的安装与使用
    docker 镜像管理
  • 原文地址:https://www.cnblogs.com/wangkangluo1/p/2130708.html
Copyright © 2011-2022 走看看