reCAPTCHA seems to not work inside a dynamic window.

718 views
Skip to first unread message

Realtruth.org

unread,
Nov 27, 2007, 5:53:31 PM11/27/07
to reCAPTCHA
As of today, reCAPTCHA no longer seems to work inside a dynamic
window. It used to.

By dynamic window, I mean several things. The simplest version, is
that we have a hidden div with a reCAPTCHA inside it, and when a user
clicks a button, the div shows. reCAPTCHA used to be fine with this,
but now it has some kind of error, when I show the div, it shows a
javascript error and then deletes the contents of the entire page (at
least on the screen). It then hangs the browser and says it is waiting
on api.reCAPTCHA.

The other place where this happens is if I place a reCAPTCHA image
inside a jquery thickbox. (http://jquery.com/demo/thickbox/)

Is there a workaround to make it so reCAPTCHA is comfortable inside
dynamic divs?

Thanks.

reCAPTCHA Support

unread,
Nov 27, 2007, 6:00:13 PM11/27/07
to reca...@googlegroups.com
Hi,

Are you using the AJAX API? This is your best bet if you are showing the CAPTCHA dynamically (http://recaptcha.net/apidocs/captcha/client.html).

It'd really help to see an example of this problem in HTML. That would help us to debug the issue.
--
reCAPTCHA: stop spam, read books
http://recaptcha.net

Realtruth.org

unread,
Nov 28, 2007, 9:41:24 AM11/28/07
to reCAPTCHA
Sure.

http://www.realtruth.org/comments.html

Right now, I just have the block show all the time.

This block:
<div id="commentBlock">

The only difference I would make to the page is I would change it to:
<div id="commentBlock" style="display:none">

I am working on trying to use the Ajax library now. I was using the
PHP code up to this point. We will see how it works out :)

Thanks.

On Nov 27, 6:00 pm, "reCAPTCHA Support" <supp...@recaptcha.net> wrote:
> Hi,
>
> Are you using the AJAX API? This is your best bet if you are showing the
> CAPTCHA dynamically (http://recaptcha.net/apidocs/captcha/client.html).
>
> It'd really help to see an example of this problem in HTML. That would help
> us to debug the issue.
>

reCAPTCHA Support

unread,
Nov 28, 2007, 10:26:16 AM11/28/07
to reca...@googlegroups.com
Hi, I'm not sure what the issue is with this page. What steps can I take to reproduce the issue?

Realtruth.org

unread,
Nov 28, 2007, 10:35:37 AM11/28/07
to reCAPTCHA
Currently, with the ajax library, I am receiving the error
"Recaptcha.widget has no properties" - recaptcha.js (line 312)

The line with the error: "Recaptcha.widget.innerHTML = "<div
id='recaptcha_area'>" + html + "</div>";"

This is when I try to do the show Recaptcha

Recaptcha.create("PUBLIC_KEY",
"reCAPTCHA", {
theme: "white"
});

Also, if I just try putting the API line in directly, with:
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<your_public_key>">
</script>

I get the same error I originally mentioned:
"RecaptchaState is not defined" recaptcha.js (line 459)
This is on the line:
var $ST = RecaptchaState;
It then blanks the contents of the screen and hangs.

I will keep working on it and keep you apprised, but if you have any
ideas I would appreciate it.

Realtruth.org

unread,
Nov 28, 2007, 10:44:27 AM11/28/07
to reCAPTCHA
I created a copy of the page with the change so you can see exactly
what happens. The page is here:
http://www.realtruth.org/commentsTest.html

Thanks.

Realtruth.org

unread,
Nov 28, 2007, 10:48:18 AM11/28/07
to reCAPTCHA
Oh, by the way, you would have to scroll to the bottom and click the
"Comments?" link to see the effect.

reCAPTCHA Support

unread,
Nov 28, 2007, 12:06:00 PM11/28/07
to reca...@googlegroups.com
To include the AJAX api, you need to write:

<script type="text/javascript" 
src="http://api.recaptcha.net/js/recaptcha_ajax.js "></script>

You don't include /challenge with the AJAX api.

The reason you are getting errors on the page that you posted is because jquery is re-evaluating scripts in the dynamic region. You should include the recaptcha_ajax.js script in the <head> of the document.

On 11/28/07, Realtruth.org <jeffrey...@gmail.com> wrote:

Realtruth.org

unread,
Nov 28, 2007, 12:44:52 PM11/28/07
to reCAPTCHA
Ok. Moving the javascript include inside <head> works on this page.

Thank you for the help!

The other page I am working on, I don't really have a publicly
available example yet, so it might be a little harder to debug.
However, the concept is fairly simple. I am trying to get the
reCAPTCHA API to load inside a jQuery thickbox.

Using the PHP code to generate it doesn't work well. However, using
the same Ajax method that we just got working on the other page, it
does not work inside a thickbox. The error I get on this page is
this:

Recaptcha.widget has no properties
_init_builtin_theme()recaptcha_ajax.js (line 312)
_finish_widget()recaptcha_ajax.js (line 366)
challenge_callback()recaptcha_ajax.js (line 256)
[Break on this error] Recaptcha.widget.innerHTML = "<div
id='recaptcha_area'>" + html + "</div>";

Have you ever encountered this before?
Once again, I appreciate the help.

reCAPTCHA Support

unread,
Nov 28, 2007, 4:25:15 PM11/28/07
to reca...@googlegroups.com
It sounds like maybe you tried to pass an ID to the create function that wasn't yet in the DOM? It's going to be hard to debug this without an example though

On 11/28/07, Realtruth.org <jeffrey...@gmail.com> wrote:

Fredrik

unread,
Nov 29, 2007, 7:07:18 AM11/29/07
to reCAPTCHA
I had the same problem and made a workaround.
It is almost the same solution as you made, but actually not.
I made it just like

setTimeout('Recaptcha.create("PUBLIC_KEY","reCAPTCHA", {theme:
"white"})',5);

it seems to work for me which I'm at least happy with.

On 28 Nov, 18:44, "Realtruth.org" <jeffreyd.da...@gmail.com> wrote:
> Ok. Moving the javascript include inside <head> works on this page.
>
> Thank you for the help!
>
> The other page I am working on, I don't really have a publicly
> available example yet, so it might be a little harder to debug.
> However, the concept is fairly simple. I am trying to get the
> reCAPTCHA API to load inside a jQuery thickbox.
>
> Using thePHPcode to generate it doesn't work well. However, using
> the sameAjaxmethod that we just got working on the other page, it

Realtruth.org

unread,
Nov 29, 2007, 9:31:34 AM11/29/07
to reCAPTCHA
That worked! Thanks for the help!

Now I just need to read the documentation on having multiple CAPTCHAs
on one page (two different sections).
Reply all
Reply to author
Forward
0 new messages