我在单个页面中实现了两个 recaptcha,但只有一个 recaptcha 在工作
我的代码用于验证码 1
<div class="resumator-label resumator-resume-text" id="resumator-recaptcha_forward-label">Human Check*</div>
<div class="resumator-input" id="resumator-recaptcha_forward-field">
<div id="div_error_resumator-forward-recaptcha-value" class="dv_error"><span>Please enter the text:</span></div><script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y"></script>
<noscript>
<iframe src="//www.google.com/recaptcha/api/noscript?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y" 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>
其他验证码
<div class="resumator-field-wrapper resumator-resume-text" id="resumator-recaptcha">
<div class="resumator-label resumator-resume-text" id="resumator-recaptcha-label">Human Check*</div>
<div class="resumator-input" id="resumator-recaptcha-field">
<script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y"></script>
<noscript>
<iframe src="//www.google.com/recaptcha/api/noscript?k=6Ld99tsSAAAAAIy-Zv3YKxCOefk2IXELOBVNhM7Y" 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>
</div>
我也用过克隆版,效果很好
//复制我们的 reCapcha
$('#resumator-recaptcha-label').html($('#resumator-recaptcha_forward').clone(true,true));
克隆验证码中的问题其重新加载验证码和其他链接不适用于新的克隆验证码
最佳答案
您可以尝试在第二个 recaptcha 加载器按钮中添加新类,然后将事件绑定(bind)到该类上并单击事件,然后再次克隆您的节点并使用 setTimeout 函数等待重绘验证码 希望对你有帮助
setTimeout(function() {
$( "#resumator-recaptcha #recaptcha_widget_div #recaptcha_reload_btn " ).addClass("reload_captcha");
$(document).on('click', '.reload_captcha', function(e){
$('#resumator-recaptcha-label').html($('#resumator-recaptcha_forward').clone(true,true));
$( "#resumator-recaptcha #recaptcha_widget_div #recaptcha_reload_btn " ).addClass("reload_captcha");
});
}, 2000);
关于javascript - 如何在单个页面中启用多个 reCAPTCHA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22455987/