When writing JS scripts, the code similar to the following always produces inexplicable problems and cannot be located. Function classname ()
...{
VaR _ HANDLE = NULL;
Function intervalfunction ()
...{
Alert ("Run intervalfunction ()");
Window. clearinterval (_ HANDLE );
_ HANDLE = NULL;
}
_ HANDLE = Window. setinterval ("intervalfunction ();", 1000 );
}
VaR OBJ = new classname ();
Annotate the code line by line, and finally find that: The function added to window. setinterval () must be a global function, and the private method of the class cannot be used here. Modify the Code as follows to solve the problem: function classname ()
...{
VaR _ HANDLE = NULL;
This. intervalfunction = function ()
...{
Alert ("Run intervalfunction ()");
Window. clearinterval (_ HANDLE );
_ HANDLE = NULL;
}
_ HANDLE = Window. setinterval ("obj. intervalfunction ();", 1000 );
}
VaR OBJ = new classname ();