Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is reCaptcha Stealing Focus on Page Load

Recaptcha has suddenly started stealing the focus when it's loaded on a page, which causes the page to scroll down to the form (very annoying). This appears to be a new bug?

See example: http://www.gullixson.com/Contact-Us

Apparently, the main Google Library that loads reCaptcha http://www.google.com/recaptcha/api/challenge?k=UNIQUEAPIKEY&lang=en calls for a http://www.google.com/recaptcha/api/js/recaptcha_canary.js

In there, the init() function appears to fire a reload() function, which is causing the Recaptcha.focus_response_field() function to load.

There appears to be nothing we can do... until they fix it?

Does anyone know how to report this bug to Google? Or a way to work around this?

like image 518
Chadwick Meyer Avatar asked Apr 26 '14 01:04

Chadwick Meyer


1 Answers

The easiest workaround is just to redefine Recaptcha.focus_response_field after the recaptcha JS has loaded.

// Load recaptcha JS

// ...

Recaptcha.focus_response_field = function(){return false;};

This makes the focus operation essentially turn into a non-op.

Edit: Tested and working on Chrome, Firefox and IE9

like image 66
Mitch Dempsey Avatar answered Sep 28 '22 05:09

Mitch Dempsey