“Stack overflow in line 0” on Internet Explorer

2019-01-22 05:38发布

I realise this is not the ideal place to ask about this in terms of searchability, but I've got a page whose JavaScript code throws "Stack overflow in line 0" errors when I look at it in Internet Explorer.

The problem is quite clearly not in line 0, but somewhere in the list of stuff that I'm writing to the document. Everything works fine in Firefox, so I don't have the delights of Firebug and friends to assist in troubleshooting.

Are there any standard causes for this? I'm guessing this is probably an Internet Explorer 7 bug or something quite obscure, and my Google-fu is bringing me little joy currently. I can find lots of people who have run into this before, but I can't seem to find how they solved it.

13条回答
够拽才男人
2楼-- · 2019-01-22 06:30

I ran into this problem recently and wrote up a post about the particular case in our code that was causing this problem.

http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/

The quick summary is: recursion that passes through the host global object is limited to a stack depth of 13. In other words, if the reference your function call is using (not necessarily the function itself) was defined with some form window.foo = function, then recursing through foo is limited to a depth of 13.

查看更多
在下西门庆
3楼-- · 2019-01-22 06:30

I set up a default project and found out the following:

The problem is the combination of smartNavigation and maintainScrollPositionOnPostBack. The error only occurs when both are set to true.

In my case, the error was produced by:

<pages smartNavigation="true" maintainScrollPositionOnPostBack="true" />

Any other combination works fine.

Can anybody confirm this?

查看更多
smile是对你的礼貌
4楼-- · 2019-01-22 06:31

If you came here because you had the problem inside your selenium tests: IE doesn't like By.id("xyz"). Use By.name, xpath, or whatever instead.

查看更多
别忘想泡老子
5楼-- · 2019-01-22 06:32

In my case I had two functions a() and b(). First was calling second and second was calling first one:

var i = 0;
function a() { b(); }
function b() {
  i++; 
  if (i < 30) {
    a();
  }
}

a();

I resolved this using setTimeout:

var i = 0;
function a() { b(); }
function b() {
  i++; 
  if (i < 30) {
    setTimeout( function() {
      a();
    }, 0);
  }
}

a();
查看更多
We Are One
6楼-- · 2019-01-22 06:33

  1. Internet Options
  2. Tools
  3. Internet options
  4. Advanced
  5. Navigation section
  6. Click > Disable script debugging

    display a notification about every script error

  7. sign in
  8. You will smile !

查看更多
可以哭但决不认输i
7楼-- · 2019-01-22 06:34

My was "at line 1" instead but...

I got this problem when using jQuery's .clone method. I replaced these by using making jQuery objects from the html string: $($(selector).html()).

查看更多
登录 后发表回答