未捕获的类型错误:不能设置属性'innerHTML'在recaptcha_ajax.js中的null

Uncaught TypeError: Cannot set property 'innerHTML' of null in recaptcha_ajax.js

本文关键字:recaptcha innerHTML ajax null 中的 js 错误 类型 不能 设置 属性      更新时间:2023-09-26

我在我的网站使用google recapthca .我的网站链接是http://yundantik.com/tr/ileti%C5%9Fim.html

当我点击地图图像在网站的右边打开iframe和关闭后,得到'Uncaught TypeError: Cannot set property 'innerHTML' of null'此错误。

你可以在控制台检查这个错误。

如何修复这个错误?

谢谢

如果您查看DOM,您可能会看到在提交表单时添加的一堆iframe。我发现添加

$("iframe").remove ();

表单提交代码之后,每次都显示验证码

这是关于您想要创建验证码的div的id。检查id是否正确。在创建reCpatcha之前,检查id是否真的存在:

if($("#captcha").length) {
  Recaptcha.create("here_is_your_key", "captcha", {
    theme: "clean"
  });
}