'Recaptcha' undefined error in 1.6.1 under IE8 only

Topics: Controls
Oct 29, 2010 at 7:13 PM

I am having a strange error.  It only occurs in 1.6.1 under IE (8 to be exact).  It does not occur with Firefox.

I get the following page error:

Webpage error details

Message: 'Recaptcha' is undefined
Line: 351
Char: 4
Code: 0
URI: http://www.madeinsatx.com/blogengine/post/Who-Needs-The-Great-Pumpkin-Charlie-Brown.aspx

 

When I look at the rendered page source I see at Line 351:

<script type="text/javascript">
   function showRecaptcha() {
   Recaptcha.create('6LengrwSAAAAAOaL8Gr9PyWyuisIOPMT0sLwJWLp', 'recaptcha_placeholder', {    <--- This is the line 351 where the error is occuring.
   theme: 'white',
   tabindex: 8
   })
   }
   var rc_oldonload = window.onload;
   if (typeof window.onload != 'function') {
   window.onload = showRecaptcha;
   }
   else {
   window.onload = function() {
   rc_oldonload();
   showRecaptcha();
   }
   }
 
  </script>

 

For the life of me I don't know why this doesn't happen in Firefox.  But since most of my site traffice is coming from IE, its keeping my comment traffic down.

Please help,

Rob

Oct 29, 2010 at 8:10 PM

Could you try to move your google analytics code to right before the closing body tag (</body>)?  I'm wondering if that could be causing the problem...

(btw, the reason why you're seeing this in IE only is probably because of the defer attribute on the recaptcha_ajax.js script include. I can't remember why I put it there, but I'm pretty sure it was necessary to get something to work... its been a while...  I'm thinking that the GA code could be messing up the order of things happening on the page, so that's why I want to see if moving it fixes the problem).

Oct 29, 2010 at 8:23 PM

I moved it just as you requested.  Problem still exists.  Very strange!

Oct 29, 2010 at 8:41 PM

Hmm... well, I really don't have any other ideas.  BTW, I just went on your site in IE8 and was able to post a comment (and complete the recaptcha).

Can you reproduce this error on other PCs?

OK... one other idea: See if this problem still occurs when you are not logged in to your site.

Oct 29, 2010 at 8:45 PM

Ok its actually the opposite fstanek.  If I am logged in, I dont get the error.  If I am not logged in, I get the error.  If you are saying your not getting it, Im gonna assume its my IE8 config.

Oct 29, 2010 at 8:52 PM

By default, I believe the recaptcha is set not NOT show up when you're logged in (it is a setting that you can change, though).  So if you're not getting the error, it probably is because the recaptcha isn't attempting to show in the first place.

However, as to the error, I'm really out of ideas as to what can be happening.  I can't really debug it from this point since I'm not seeing the error. :(

If you have access to another PC running IE8, I would try to see if it happens there as well.  If it doesn't, at least it could offer you some piece of mind that it is most likely something about your IE instance.

 

Coordinator
Oct 29, 2010 at 9:00 PM

As Filip hinted at once here, I would remove the DEFER attribute from the script.  We were using the DEFER attributes on all scripts before, but have abandoned that since it can cause timing related problems -- especially now that we are including jQuery and people might have plugins, etc that depend on jQuery being loaded.

You can remove the DEFER attribute in the RecaptchaControl.cs file (in the App_Code\Extensions\Recaptcha folder).  On line 549 should be:

output.AddAttribute("defer",·"defer");

Just delete that line, or comment it out.

Oct 29, 2010 at 10:07 PM

Thanks BenAmada and fstanek. I removed output.AddAttribute("defer","defer); line of code and its working now.

Really appreciate the help!  Should this change be pushed into the next release?  If so, should I make a request to have that line removed?

Coordinator
Oct 29, 2010 at 11:47 PM

That's good to hear.  That line was just recently removed from a developer builder (in the last week).  The next version of BE will have this updated code (i.e. no more DEFER).