ReCaptcha doesn't work in Safari/Chrome in modal jQuery dialog

767 views
Skip to first unread message

Martijn

unread,
Jun 10, 2011, 6:10:50 AM6/10/11
to reCAPTCHA
If I want to show the ReCaptcha in a modal jQuery dialog (I've tried
blockUI, SimpleModal and ThickBox), the page reloads with just the
ReCaptcha iframe content, instead of showing it as part of a form in a
modal dialog.

It works fine in Firefox. Any idea what the problem could be? I can't
find a solution anywhere, and I don't understand why Webkit browsers
would misinterpret an iframe like that.


mcv.

Martijn Vos

unread,
Jun 10, 2011, 12:33:51 PM6/10/11
to reCAPTCHA

A misunderstanding on my part: the iframe is between noscript tags, so
it's irrelevant to my problem. Instead, it turns out that when jquery
moves the div that contains the recaptcha, Safari rerenders the tags,
and reexecutes all the javascript. And somehow the document.write gets
confused about where it is and overwrites the entire page.

Anyway, the fix is really simple:

$('#captcha-form script').remove();


(where 'captcha-form' is the id of the form containing the captcha).
This makes sure the script tags don't get rendered twice. All the event
handlers created by the script survive this removal.

A better looking fix would be to put the recaptcha script outside the form
and let it write the captcha inside the form, but since I'm using a grails
plugin to generate all the recaptcha tags, that's less of an option for me.


mcv.

Reply all
Reply to author
Forward
0 new messages