你的函数 getparam() 每次运行 document.myApplet.setValue(bb); 这个变量 bb 都被重新定义成了15, 不管这个变量以前是如何的. 是不是? 所以程序改一下:
function getparam()
{
document.myApplet.setValue(bb);
document.myApplet.repaint();
}
bb = new String("15"); //这句放到函数外来赋值, 这样只要这个变量有变化, 函数里的那个参数值也就跟着变化了.
function getparam()
{
document.myApplet.setValue(bb);
document.myApplet.repaint();
}
bb = new String("15"); //这句放到函数外来赋值, 这样只要这个变量有变化, 函数里的那个参数值也就跟着变化了.
看来不是在外面赋值就行的,
function getparam(){
bb = new String("15");
document.myApplet.setValue(bb);
document.myApplet.repaint();
setInterval("getparam();",2000);
}
Contents Index Topic Contents
Previous Topic: setEndPoint
Next Topic: setTimeout
setInterval--------------------------------------------------------------------------------DescriptionRepeatedly evaluates an expression after a specified number of milliseconds has elapsed. Syntax
intervalID = object.setInterval(expression, msec [, language])Parameter Description
expression String containing the script code to execute each time the interval elapses.
msec Integer value or numeric string specifying the length of the interval, in milliseconds.
language Optional. String specifying the language in which the code is executed. Return ValueReturns an integer identifier representing the interval. Use this identifier to clear (stop) the interval. ExampleThe following example sets a 5-second interval. Each time the interval elapses, the background color of the document changes. setInterval("changeColor()", 5000);
.
.
.
function changeColor()
{
if (document.body.bgColor == "#ff0000") // Check if body bgColor is red by comparing to hexidecimal value
document.body.bgColor = "blue";
else
document.body.bgColor = "red";
}Applies Towindow See Also
clearInterval -------------------------------------------------------------------------------- Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.