Reference: 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; charsets = UTF-8" />
< Title > Untitled document </ 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 );
}
/*
This function puts the function to be paused in the Array Window. eventlist, and calls the continue function through setTimeout.
The continuation function is as follows:
*/
Function Goon (IND)
{
VaR OBJ = Window. eventlist [ind];
Window. eventlist [ind] = Null ;
If (Obj. nextstep) obj. nextstep ();
Else OBJ ();
}
/*
Call the nextstep method of the suspended function. If this method is not available, call the function again.
After the function is compiled, we can perform the following operations:
*/
Function Test ()
{
Alert ( " Hellow " );
Pause ( This , 5000 ); // Call the pause function
This . Nextstep = Function ()
{
Alert ( " Nextstep " );
}
}
</ Script >
</ Head >
< Body Onload = "Test ()" >
< Div Class = "Center" > Test </ Div >
</ Body >
</ Html >
End