IE Stack Overflow Javascript Fix
Fix for calling the same function a few times in an almost infinite loop using the onchange event and getting a stack overflow at line 0 or any other line error in Internet Explorer:
function MyFunction(currentTextBox, nextTextBox)
{
//magic code in here
//when magic finished, call next magic spell
setTimeout(function(){FireNextBox(nextTextBox},1);}
function FireNextBox(nextTextBox)
{
nextTextBox.onchange();
}
//for last textbox in loop
function FinalFunction()
{
return;
//the end
}
The above scenario assumes the onchange event calls ‘MyFunction’ and there is a return function available, ‘FinalFunction’ that is called by the onchange event of the last textbox in this loop. Using setTimeout is necessary in Internet Explorer, otherwise it will throw a stack overflow error, works fine in Firefox with and without the setTimeout.





