<! 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>
<Title> </title>
<SCRIPT type = "text/JavaScript">
/* The following is taken from the prototype framework. Code ---------------------------------------*/
VaR $ A = function (iterable ){
If (! Iterable) return [];
If (iterable. toarray ){
Return iterable. toarray ();
} Else {
VaR Results = [];
For (VAR I = 0, length = iterable. length; I <length; I ++)
Results. Push (iterable [I]);
Return results;
}
}
// Closure method (the first parameter is the object of the binding method, and the following parameter is the parameter of the binding method ).
Function. Prototype. Bind = function (){
VaR _ method = This, argS = $ A (arguments), object = args. Shift ();
Return function (){
Return _ method. Apply (object, argS. Concat ($ A (arguments )));
}
}
/*-------------------------------------------------------------------*/
Function node (ID, name, CN ){
This. ID = ID;
This. Name = Name;
This.cn = cn;
}
VaR nodes = new array ();
Nodes [0] = new node (1, "node1", "Node 1 ");
Nodes [1] = new node (2, "node2", "Node 2 ");
VaR nodeconfig = {};
Nodeconfig. ticks = 4*1000; // refresh frequency
Nodeconfig. MSG = "running ";
Function showstatus (node ){
Alert (node. Name + ":" + nodeconfig. msg );
}
Function start (){
VaR Len = nodes. length;
For (VAR I = 0; I <Len; I ++ ){
// Closure.
VaR bindfun = showstatus. BIND (null, nodes [I]);
Setinterval (bindfun, nodeconfig. ticks );
}
}
Start ();
</SCRIPT>
</Head>
<Body>
<Input id = "button1" type = "button" value = "button" onclick = "TT ();"/>
</Body>
</Html>
ReferenceArticle: Http://www.cnblogs.com/KevinYang/archive/2009/07/14/1522915.html