【问题标题】:reCAPTCHA Permission denied to access propertyreCAPTCHA 访问属性的权限被拒绝
【发布时间】:2018-12-12 21:25:32
【问题描述】:

当我单击该框以确认我不是机器人时,蓝色微调器开始旋转但从未停止。最终错误“错误:访问属性的权限被拒绝”出现在浏览器控制台中,后跟一个(看似)随机的 10 -15 字符串,例如“rne4xiajwyh”。

我的代码:

<script type="text/javascript">
  var onloadCallback = function() {
    grecaptcha.render('html_element', {
      'sitekey' : 'my_site_key'
    });
  };
</script>

<form action="#" method="POST">
  <div id="html_element"></div>
  <br>
  <input type="submit" value="Submit">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
    async defer>
</script>

我正在努力解决这个问题,因为我在网上找不到任何解决方案,并且不确定如何调试它。任何帮助将不胜感激。

谢谢

编辑:chrome 中的错误消息:

Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.
    at Dp.f.Ub (https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__pl.js:349:353)
    at Dp.vb (https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__pl.js:345:59)

【问题讨论】:

标签: javascript recaptcha


【解决方案1】:

看来您必须允许跨域请求:

如果你运行 apache(它也可能被粘贴在 .htaccess 中):

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin https://www.gstatic.com
</IfModule>

或者用php:

header("Access-Control-Allow-Origin: https://www.gstatic.com");

或者使用 nginx(服务器部分):

add_header Access-Control-Allow-Origin https://www.gstatic.com; # < this is the needed header

【讨论】:

  • 如果不行,试试用google替换gstatic
【解决方案2】:

<head> ... <META HTTP-EQUIV="Access-Control-Allow-Origin" CONTENT="@987654321@"> ... </head>

Error: Permission denied to access property “document”

【讨论】:

    猜你喜欢
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 2015-03-18
    • 2016-09-02
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多