admin 管理员组文章数量: 1086019
I have two domains, a and b, both with reCAPTCHA enabled. I'm using the same codebase for both websites, but the reCAPTCHA implementation works on a but not on b. Here's the setup:
a: The reCAPTCHA keys were created by a friend 2 years ago. The keys are for reCAPTCHA v3, as the site uses grecaptcha.execute.
b: The reCAPTCHA keys were created today, and I used reCAPTCHA v3 for this domain as well.
On b, I get an error:
contact.php:37 Uncaught (in promise) TypeError: Cannot set properties of null (setting 'value')
at contact.php:37:71
(anonymous) @ contact.php:37
Promise.then
then @ recaptcha__en.js:591
(anonymous) @ contact.php:36
Promise.then
(anonymous) @ recaptcha__en.js:138
(anonymous) @ recaptcha__en.js:195
(anonymous) @ recaptcha__en.js:196
(anonymous) @ recaptcha__en.js:472
(anonymous) @ recaptcha__en.js:196
(anonymous) @ recaptcha__en.js:1132
(anonymous) @ recaptcha__en.js:1142
Here's the client-side code I’m using:
<script src=".js?render=mysitekey"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('mysitekey', {action: 'contact_form'})
.then(function(token) {
document.getElementById('g-recaptcha-response').value = token;
});
});
</script>
Also I noticed that the reCAPTCHA tokens generated for the two domains have different lengths:
For a, the token is about 1100 characters.
For b, the token is around 2400 characters.
Can someone tell me what is wrong with this code?
本文标签: javascriptErrorCannot set properties of null when using recaptchaStack Overflow
版权声明:本文标题:javascript - Error : Cannot set properties of null when using recaptcha - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744038493a2522817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论