最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "undefined handler" from prototype.js line 3877 - Stack Overflow

programmeradmin5浏览0评论

A very niche problem:

I sometimes (30% of the time) get an 'undefined handler' javascript error on line 3877 of the prototype.js library (version 1.6.0.2 from google: .6.0.2/prototype.js).

Now on this page I have a Google Map and I use the Prototype Window library.

The problem occurs in IE7 and FF3.

This is the info FireBug gives:

handler is undefined
? in prototype.js@3871()prototype.js (line 3877)
handler.call(element, event);

I switched to a local version of prototypejs and added some debugging in the offending method (createWraper) but the debugging never appears before the error...

I googled around and found 1 other mention of the error on the same line, but no answer so I'm posting it here where maybe, some day someone will have an answer :).

A very niche problem:

I sometimes (30% of the time) get an 'undefined handler' javascript error on line 3877 of the prototype.js library (version 1.6.0.2 from google: http://ajax.googleapis./ajax/libs/prototype/1.6.0.2/prototype.js).

Now on this page I have a Google Map and I use the Prototype Window library.

The problem occurs in IE7 and FF3.

This is the info FireBug gives:

handler is undefined
? in prototype.js@3871()prototype.js (line 3877)
handler.call(element, event);

I switched to a local version of prototypejs and added some debugging in the offending method (createWraper) but the debugging never appears before the error...

I googled around and found 1 other mention of the error on the same line, but no answer so I'm posting it here where maybe, some day someone will have an answer :).

Share Improve this question edited Dec 27, 2011 at 16:31 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Sep 4, 2008 at 12:09 Boy BaukemaBoy Baukema 2,9701 gold badge29 silver badges42 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

I just found out this error also occurs if you accidentally leave on the parenthesis on your observer call:

Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp());

instead of

Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp);

This will probably cause an error:

Event.observe(myElement, 'click', myFunction(myParameters));

You should do it like this instead:

Event.observe(myElement, 'click', function() { myFunction(myParameters) });

I switched to a local version of prototypejs and added some debugging in the offending method (createWraper) but the debugging never appears before the error...

Actually the offending function being called when the error occurs is "wrapper" which is created inside createWrapper (but not called there). Basically what is happening is that you've attached a function as the event handler for an element, and the function doesn't actually exist.

If you're trying to put any debug information in to try and pinpoint which function "doesn't exist" then add your alert messages or firebug console output inside the wrapper function between lines 3871 and 3878.

Really simple solution for “undefined handler” from prototype.js error in Prototype is just... fix prototype. I found advice here: https://prototype.lighthouseapp./projects/8886/tickets/407-ie7-i8-report-handler-is-null-or-not-an-object and it's actually working.

Just find line with: handler.call(element, event); and replace with if (handler) handler.call(element, event) problem solved with prototype 1.6.0.3 and latest :)

发布评论

评论列表(0)

  1. 暂无评论