ReCAPTCHA ajax加载主题问题
无法弄清楚如何主题化 ajax 加载的验证码。下面的代码不起作用。
来自 Google Recaptcha
看到了这篇文章< a href="https://stackoverflow.com/questions/2458187/recaptcha-ajax-api-custom-theme-not-working">Recaptcha ajax API 自定义主题不起作用,但我肯定是在本地主机中查看验证码工作正常,只是不改变主题。
有人对如何让白色主题工作有建议吗?
<script type='text/javascript'>
var RecaptchaOptions = {
theme : 'white'
};
</script>
<div id="recaptcha_content">
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type='hidden' name='recaptcha_response_field' value='manual_challenge' />
</noscript>
</div>
<script type="text/javascript">
$(document).ready(function() {
$.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
function() {Recaptcha.create("6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q", "recaptcha_content");
});
});
</script>
Can not figure out how to theme an ajax loaded recaptcha. The below code does not work.
From Google Recaptcha
Saw this post Recaptcha ajax API custom theme not working, but I am definitely viewing in localhost and recaptcha is working fine, just not changing themes.
Anyone have advice on how to get the white theme to work?
<script type='text/javascript'>
var RecaptchaOptions = {
theme : 'white'
};
</script>
<div id="recaptcha_content">
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type='hidden' name='recaptcha_response_field' value='manual_challenge' />
</noscript>
</div>
<script type="text/javascript">
$(document).ready(function() {
$.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
function() {Recaptcha.create("6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q", "recaptcha_content");
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
@jhanifen:在使用 http://wiki.recaptcha.net/index.php/ 中的大部分代码后,我得到了它的工作安装,试试这个——
@jhanifen: I got it working after using most of the code from http://wiki.recaptcha.net/index.php/Installation, try this --
我看起来不像您要添加已设置的选项
RecapthcaOptions
。尝试更改为:查看文档,传递给的第三个选项
.create()
方法是选项。您在函数外部设置一个变量来设置选项,但不包含它们。I't doesn't look like you are adding your options that you have set
RecapthcaOptions
. Try changing to:See the doc's, the third option passed to the
.create()
method is the options. You are setting up a variable outside the function to set the options, but don't include them.首先,您的密钥无效或错误,或者您希望将其发布在这里:D
如果不想要的话。尝试获取一个新的,也许将其设为全局的(可能会影响本地主机的东西)。或者在您指定的域上上传并测试代码。
该片段适用于我的全局公钥,我直接在创建时设置主题
First of all, your key is invalid or wrong, or you wanted that to be posting here :D
If not wanted. try to get a new one, and maybe make it a global one (could affect the localhost stuff). Or upload and test the code on the domain you specified.
This snippet works for my global public key, i set the theme directly on creation
按照奥卡姆剃刀的方式,您可以验证设置主题的脚本是否位于表单元素之前。正如文档中多次所述,该脚本在表单元素内部或之后不起作用。
Going the Occam's Razor way, can you verify that the script for setting the theme is before the form element. As stated several times in the docs, the script does not work inside or after the form element.