Re: reCAPTCHA implementation problems

On Fri, 13 Jul 2007, Chris Blouch wrote:

> There is an odd bit of script which appears to be trying to move focus to the 
> input field over and over until it succeeds.
>
> function focus() {
> try {
>   Recaptcha.focus_response_field();
> }
> catch (e) {
>   window.setTimeout(focus, 100); // IE hack
> }
> }
> focus();
>
> Any particular reason for this? If it's a race state issue because you might 
> be moving focus before the form field exists, you could just add the focus 
> move to the onload event of the page body. Then the move wouldn't fire until 
> the page is fully loaded. I believe that because your scripts are inline the 
> onload event wouldn't fire until your script, which document.writes another 
> script tag, is fully executed. Doing it this way also means you could have 
> your included script do this task rather than having the integrator start 
> another script block and come up with their own focus move code. You could 
> simply move focus as the last line of your injection of the content into the 
> page.

Colin -- why the hack for IE? (Colin McMillen is one of our hackers)

> The focus move should probably be controlled by and optional URL parameter or 
> boolean in the RecaptchaOptions structure. The captcha form on some 
> integrations might be at the bottom of a page where users are filling in 
> other stuff before the final captcha and submit. In this scenario yanking 
> focus from the top of the page to the captcha would be rather jarring.

The focus-moving is mostly for the demo. It makes it much easier to try 
out the demo (sort of like the google.com homepage). Also, we move the 
focus to the input box after you switch to/from an audio captcha. Any 
thoughts on this?

-b

Received on Friday, 13 July 2007 17:36:55 UTC