That's why this function is not provided in js?
Currently, all browsers parse js in the UI thread. Taking Firefox as an example, I re-compiled the js engine and added the sleep method to the js alert. This method calls the C language thread sleep function.
Attaches the method to the Object, and the method signature is sleep (); No parameter. The default sleep is 1 second. If you call this function in js, the browser UI interface will be blocked.
In addition, if your js function has an endless loop, the browser's js parsing will detect js execution timeout and remind you whether to terminate the execution of js on this page.
Finally, a newly compiled js engine is provided. replace them with the js engine in firefox.
Then you can write a piece of js for fun, such as "testSleep". sleep (); because I added it to an Object, you can call this function on any js Object.
Instructions for use:
It is mainly because Website Visitors need to install your customized browser.
You just need to release the Firefox client.
You must specify your own browser, just as you must install the flash plug-in.
Attachment: firefox_js.rar