Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fooling the Internet Explorer Javascript engine into letting a script run

I'm repeatedly coming into troubles with Internet Explorer's "This script is taking too long to run, would you like to continue?" messages. I am wondering if anyone is aware of a clever way to trick the JS engine into keeping quiet? Based on some searching I did, I found that the engine monitors states it thinks potentially could be infinitely looping, so I thought maybe I could add some logic to change up the execution every once in a while to fool it into leaving it alone, but no luck. I also tried breaking up a longer loop into several shorter ones, but that hasn't helped. Specifically the code that is currently causing issues is the expansion of nodes in a tree structure. The code is looping over the current nodes and expanding each. It's a trivial thing to write in Javascript, but I can't allow these timeout errors, so I think my only option might be to request pre-expanded view data via AJAX. I'm currently working in a DEV environment with a small(ish) data set and I know this will not fly in other environments. Has anyone managed to suppress these warnings?

like image 923
Adam Avatar asked Jun 21 '10 20:06

Adam


2 Answers

Using setTimeout

A good way is simulating threaded execution using setTimeout() function calls. This requires splitting your whole processing into smaller parts and queueing them one after another. Timeouts can be set quite close to each other but they will run one by one when each of them finishes execution.

like image 184
Robert Koritnik Avatar answered Oct 02 '22 14:10

Robert Koritnik


How about spacing it using a series of events. So a loop occurs sends an event, listener to event triggers and does a loop. etc..?

like image 39
John Avatar answered Oct 02 '22 15:10

John