Entry
I wrote a script that goes through a bunch of loops. How do I stop IE asking if I want to continue?
Apr 6th, 2008 19:30
ha mo, Neil Hardie, Mike Skott,
Can you post an example of your code and the exact message?
It sounds like you're getting into an infinite loop, i.e. there's
something wrong with your code, which is why IE is asking if you really
want it to continue processing something it's identified as an infinite
task.
----
I am trying to run a particular function exactly 10,000 times. I think
the browsers *think* I am executeing an infinite loop, but I am
in actuality just looping 10,000 times. I tried splitting it into a
loop that runs 100 times executing a different loop that runs my
function 100 times, but it paused and asked if I wanted to abort at the
same time. I have also tried using setTimeout to try to get the
browser to realize I am *trying* to loop this many times.
----
I've just tried this example with no problems in ie5.5:
<script language="JavaScript1.2">
function callingFunction() {
for(i=0;i<10000;i++){
loopedFunction(i);
}
}
function loopedFunction(j) {
document.getElementById('feedback').innerText = j;
}
</script>
<body onload="callingFunction();">
<div id="feedback"></div>
</body>
But be aware that this locks your page until the loop is complete. If
this should run in the background, better to use setTimeout or
setInterval, something like this which will called loopedFunction every
millisecond until i == 10000 ...
function callingFunction() {
i = 0;
myInterval = setInterval('loopedFunction()',1);
}
function loopedFunction() {
i++;
if(i==10000)
myInterval = null;
}
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com