Business web hosting - 284 Part III . Document Objects Reference that

284 Part III . Document Objects Reference that appear in other frames or as layers, perhaps changing the view every ten seconds. Clock displays and countdown timers would also be suitable usage of this method (even though you see examples in this book that use the old-fashioned setTimeout() way to perform timer and clock functions). In contrast, setTimeout() is best suited for those times when you need to carry out a function or expression one time in the future even if that future is only a second or two away. See the discussion of the setTimeout()method later in this chapter for details on this application. While the primary functionality of the setInterval()method is the same in both NN and IE, each browser offers some extra possibilities depending on the way you use parameters to the method. For simple invocations of this method, the same parameters work in all browsers that support the method. First, I address the parameters that all browsers have in common. The first parameter of the setInterval()method is the name of the function or expression to run after the interval elapses. This item must be a quoted string. If the parameter is a function, no function arguments are allowed inside the function s parentheses unless the arguments are literal strings (but see the section Passing Function Parameters ). The second parameter of this method is the number of milliseconds (1,000 per second) that JavaScript should use as the interval between invocations of the func tion or expression. Even though the measure is in extremely small units, don t rely on 100 percent accuracy of the intervals. Various other internal processing delays may throw off the timing just a bit. Just as with setTimeout(), setInterval() returns an integer value that is the ID for the interval process. That ID value lets you turn off the process with the clearInterval() method. That method takes the ID value as its sole parameter. This mechanism allows for the setting of multiple interval processes running, while giving your scripts the power to stop individual processes at any time without interrupting the others. IE4+ uses the optional third parameter to specify the scripting language of the statement or function being invoked in the first parameter. As long as you are scripting exclusively in JavaScript (the same as JScript), there is no need to include this parameter. Passing function parameters NN4+ provides a mechanism for easily passing evaluated parameters to a func tion invoked by setInterval(). To use this mechanism, the first parameter of setInterval() must not be a string, but rather a reference to the function (no trailing parentheses). The second parameter remains the amount of delay. But beginning with the third parameter, you can include evaluated function arguments as a comma-delimited list: intervalID = setInterval(cycleAnimation, 500, figure1 ) The function definition receives those parameters in the same form as any function. function cycleAnimation(elemID) {…} For use with a wider range of browsers, you can also cobble together the ability to pass parameters to a function invoked by setInterval(). Because the call to the other function is a string expression, you can use computed values as part of windowObject.setInterval()
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply