So if you wanted (pseudo code)
you would stuff the code into functions:
If you wanted (pseudo code)
Note that both setInterval and setTimeout return a timer id you can use to clear the scheduled execution e.g.
A sneaky way to get the effect of a true pause while not burning CPU cycles is to use a modal dialog with a timeout that closes the modal dialog window and resumes execution. A modal dialog pauses execution in the code that created it, but allows other threads to continue.
If you want a true and CPU efficient pause, you will need to use a real language. Your best choice is Java.
CAUTION: if the JVM (Java Virtual Machine) has not yet started, there is an additional (several second) JVM start delay before your sleep call is executed. Subsequent calls will then delay the correct amount.
Officially, IE does not support Liveconnect. So, if you want a reliable cross browser solution, you can simply embed the above in a public method of a Java applet as follows:
Iana Tsolova is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.