English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This is many one of the timing events. The window object allowscode at a specifictime intervalThe object providesSetInterval()To repeat a function within a specific time period. It takes two parameters. One is the function, and the other is the time, which specifies the timerepeats executionThe time interval of this function.
window.setInterval(function, milliseconds, param1, param2, ...));
This method can also take other parameters and add them to the function.
In the following example, the method is definedsetInterval() method, and declared3000 milliseconds or3seconds interval. Therefore, the internal function provided will repeat every3seconds repeat. In9seconds within the time range, the results are displayed in the output.
<html> <body> <script> setInterval(function(){ document.write("Tutorix </br>"); }, 3000); </script> </body> </html>
Tutorix Tutorix Tutorix
In the following example, the method is defined and declared2000 milliseconds interval. Therefore, the internal function provided will repeat every2seconds repeat. The results are displayed in the output. setInterval()
<html> <body> <script> setInterval(function(){ document.write("Hello </br>"); }, 2000); </script> </body> </html>
Hello Hello