“SCRIPT28: Out of stack space” on website using IE

2019-02-21 10:09发布

问题:

I am having an issue where all link button controls on my page do not work once we deploy our website to our production server. Here are a few details:

  1. We have 3 environments upon which we develop: Our local Machine, which uses local IIS7 to run for development; test environment which is an actual webserver behind our firewall(IIS6); Production which is our live webserver(IIS6). The website works fine on local machines and test server but once we click a link button on production server it hangs.

  2. The problem does not exist in Chrome, or FireFox it only exists in IE9. It does not exist when you put IE9 in compatibility mode.

  3. If I use the IE9 Developer tool bar and watch the scripts, as soon as you click one of the link buttons the console shows this error:

SCRIPT28: Out of stack space , line 340 character 9

  1. I am using quite a bit of JQuery and am wondering if this is causing an issue: However, I see no javascript errors.

Any thoughts? Thanks for any suggestions.

回答1:

As people said in comments: it means that infinite recursion takes place. Whether it is simple recursion or some devious path across code like a serpent biting its tail - unknown, it seems IE gives out no stacktrace, or does?



回答2:

Can you post the code / a link to the code, or close this issue?

Common problems: you might have a closure problem in the html, thus different browsers interpret the html hierarchy differently, or you might be looping through a for(x in y) where x contains a backreference to y.



回答3:

Check out the msdn page for info on this error. In my case, the error was caused by:

Your code triggered an event cascade.
An event cascade is caused by triggering an event that calls an event procedure that's already on the stack. ...

Basically, I was trying to trigger a click event (using jQuery) on a file upload control using the control's click event. Seems like it would cause infinite recursion. Perhaps you may be having a similar problems with your buttons.



回答4:

I've reproduced this issue when I'm doing the following code:

HTML

<span class="search-icon"><input title="search" type="submit" value=""></span>

JS

(function($) {
    $('.search-icon').on('click', function(e) {
        // The click event will call  $('.search-icon').on('click', function(e) { .. } for every time
        // which make an infinte loop in click event as long as there are no stop condition added here.
        $(this).find('input').click();
    });
})(jQuery);

I've solve this problem by changing my JS code to be:

(function($) {
        $('.search-icon').on('click', function(e) {
            $(this).closest('form').submit();
        });
})(jQuery);

I hope this answer will be helpfull for you.