You can create a loop in JavaScript by using the 'setInterval' statement. Here's an example of an error message that will keep popping up, every four seconds.
JavaScript loop script code snippet
This script will cause an error message window to popup every four seconds or 4000 milliseconds. Simply insert this code into any HTML web page, WordPress page, WordPress post, or Facebook Page.
Javascript | | copy code | | ? |
1 | <script type="text/javascript"> |
2 | // set interval |
3 | var tid = setInterval(mycode, 4000); |
4 | function mycode() { |
5 | alert('It is time to take a 30 second break and Look Around!'); |
6 | } |
7 | </script> |