开发者

How to prevent a stack overflow in IE due to unwanted recursion

I've been searching since a while, to no avail.

On a long form, I'm doing checks with javascript, and used the attribute "onchange" to do them. Recently, I discovered that on IE, the "onpropertychange" attribute should be used, as the "onchange" event is not handled correctly.

So now, I have for example this kind of field (not all the fields have onKeyDown or onKeyUp events):

<textarea name="shdescription" rows="1" cols="75" onKeyDown="textCounter(this,'shdesccounter',65)"
onKeyUp="textCounter(this,'shdesccounter',65)" onchange="checkFormValue();" onpropertychange="checkFormValue();"></textarea>

And now each time I make a change on a field, then it takes a few seconds before registring the change and making the check. (and more when the change is made on the textarea I described.)

Firing the IE F12 debugger, I noticed that a lot of "SCRIPT28: Out of stack space" and "SCRIPT2343: Stack overflow at line:" are fired. Following the execution of the script step by step, I noticed that the script is looping between two different ajax call to PHP scripts. I'm not sure we can talk of recursion actually, as I don't see any direct link between the two function.

So I can think only of two possibilities: either there are change triggered in the field which trigger the the ajax call again, or I am doing something wrong with my ajax calls.

Where should I look开发者_Python百科 to resolve my problem? If there is need for more information, don't hesitate to ask.

PS: I don't have any problem of this sort with FF/Chrome/Opera.


I'll bet that one of the functions checkFormValue() or textCounter() is modifying the textbox in a way that is causing another event to fire which goes on to endlessly loop.

Try using onBlur.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜