//暂停函数(类似于java线程的sleep())
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);
}
//继续函数
function GoOn(ind){
var obj=window.eventList[ind];
window.eventList[ind]=null;
if (obj.NextStep) obj.NextStep();
else obj();
}
调用方式
function pausetoreclick(){
Pause(this,2000); this.NextStep=function(){
todo}
}
分享到:
相关推荐
本文实例讲述了javascript 使用sleep函数的常见方法。分享给大家供大家参考,具体如下: 一.什么是sleep函数? 花一点时间来聊一下sleep函数,首先什么是sleep函数? sleep是一种函数,他的作用是使程序暂停指定的...
我们都知道java、c#、vb等语言都有sleep暂停的函数,而JavaScript脚本没有类似的功能。
下面是一个js自定义的wait函数,可以暂停程序的执行 function sleep(delay) { var start = new Date().getTime(); while (new Date().getTime() < start + delay); } //usage //wait for 3 seconds sleep(3000...
下面代码用JS实现了程序的暂停与继续 代码如下: [removed] /*Javascript中暂停功能的实现 Javascript本身没有暂停功能(sleep不能使用)同时 vbscript也不能使用doEvents,故编写此函数实现此功能。 javascript作为...
Javascript本身没有暂停功能(sleep不能使用)同时 vbscript也不能使用doEvents,故编写此函数实现此功能。 javascript作为弱对象语言,一个函数也可以作为一个对象使用。 比如: function Test(){ alert&#...
代码如下:[removed] /*Javascript中暂停功能的实现 Javascript本身没有暂停功能(sleep不能使用)同时 vbscript也不能使用doEvents,故编写此函数实现此功能。 javascript作为弱对象语言,一个函数也可以作为一个...
同步还是异步:http://blog.iecn.net/blog/html/do-showone-tid-966.htmlJavascript中暂停功能的实现 :http://blog.csdn.net/snakegod/archive/2004/09/22/112810.aspxJavaScript Sleep函数 :...
这里的话使用的是vue.js中的setTimeout函数来解决该问题。 代码如下: var that = this; setTimeout(function () { that.modifyDialogVisible = false; grid.api.reloadData(); },500); 值得注意的是这里在...
WeiXin mini program "Sleep health mirror" for diagnose OSASH(obstructive sleep apnea-hypopnea syndrome) rapidly 云开发 quickstart 这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:...