<p>A very niche problem:</p>

<p>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: <a href="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js" rel="nofollow noreferrer">http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js</a>).</p>

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

<p>The problem occurs in IE7 and FF3.</p>

<p>This is the info FireBug gives:</p>

<pre><code>handler is undefined
? in prototype.js@3871()prototype.js (line 3877)
handler.call(element, event);
</code></pre>

<p>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...</p>

<p>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 :).</p>

[{'answer_id': 43646, 'author': 'David McLaughlin', 'author_id': 3404, 'author_profile': 'https://Stackoverflow.com/users/3404', 'pm_score': 2, 'selected': False, 'text': '<blockquote>\n  <p>I switched to a local version of prototypejs and added some debugging\n  in the offending method (createWraper) but the debugging never appears\n  before the error...</p>\n</blockquote>\n\n<p>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. </p>\n\n<p>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.</p>\n'}, {'answer_id': 175102, 'author': 'user25551', 'author_id': 25551, 'author_profile': 'https://Stackoverflow.com/users/25551', 'pm_score': 4, 'selected': True, 'text': "<p>I just found out this error also occurs if you accidentally leave on the parenthesis on your observer call:</p>\n\n<pre><code>Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp());\n</code></pre>\n\n<p>instead of</p>\n\n<pre><code>Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp);\n</code></pre>\n"}, {'answer_id': 4789535, 'author': 'Slav', 'author_id': 432573, 'author_profile': 'https://Stackoverflow.com/users/432573', 'pm_score': 2, 'selected': False, 'text': '<p>Really simple solution for <strong>“undefined handler” from prototype.js</strong> error in Prototype is just... fix prototype. I found advice here: <a href="https://prototype.lighthouseapp.com/projects/8886/tickets/407-ie7-i8-report-handler-is-null-or-not-an-object" rel="nofollow">https://prototype.lighthouseapp.com/projects/8886/tickets/407-ie7-i8-report-handler-is-null-or-not-an-object</a> and it\'s actually working.</p>\n\n<p>Just find line with: \n<code>handler.call(element, event);</code> \nand replace with \n<code>if (handler) handler.call(element, event)</code>\nproblem solved with prototype 1.6.0.3 and latest :)</p>\n'}, {'answer_id': 5219522, 'author': 'TMN', 'author_id': 648107, 'author_profile': 'https://Stackoverflow.com/users/648107', 'pm_score': 2, 'selected': False, 'text': "<p>This will probably cause an error:</p>\n\n<pre><code>Event.observe(myElement, 'click', myFunction(myParameters));\n</code></pre>\n\n<p>You should do it like this instead:</p>\n\n<pre><code>Event.observe(myElement, 'click', function() { myFunction(myParameters) });\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/43584', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4512/']