Home > Web Front-end > JS Tutorial > Sharing on how to implement JS control code pause_javascript skills

Sharing on how to implement JS control code pause_javascript skills

WBOY
Release: 2016-05-16 17:49:25
Original
1012 people have browsed it

Method 1: This is a method found online and can be used. But to be honest, I don't quite understand this method. . . It's so complicated to write. How different is this from setTimeout?

Copy code The code is as follows:

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 testJsStop() {
alert( "1");
Pause( this, 3000);
this. NextStep = function () {
alert( "2");
}
}

Method 2: This is also found online and can be used. Its principle is to pop up a window first, because when JS pops up the window, the code will pause execution at the current location. Wait for a period of time before executing the window closing function, and the code continues to execute. This method is very simple, but the annoying thing is that it will pop up a window. . .
Copy code The code is as follows:

function pause(numberMillis) {
addcloud() ;
var dialogScript = 'window.setTimeout(' ' function () { $("#bgDiv").remove(); }, ' numberMillis ');';
var result = window.showModalDialog(' javascript:document.writeln(' '"
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template