PeterBushMan Posted March 15 Share Posted March 15 Example, show a slow typed message using sleep() method as other programming languages do. Link to comment Share on other sites More sharing options...
pzkpfw Posted March 15 Share Posted March 15 Did you abandon your previous thread? I'm assuming (not "suing"!) you mean JavaScript not POstScript here, too. JavaScript has no sleep. The idea of blocking code in something built for the UI is an anathema. However, you can fake it. The following works. It wraps the setTimeout in a promise, then uses await to block on it. <html> <head><title>Not a great general purpose programming environment</title></head> <body> <script> ShowLine("You can't always get what you want."); function sleep(ms = 0) { return new Promise(resolve => setTimeout(resolve, ms)); } async function ShowLine(input) { for (let i = 0; i < input.length; i++) { await sleep(250); document.write(input[i]); }; } </script> </body> </html> It seems to me you're really needing something else to do your programming with. (But you don't provide much detail to work with.) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now