2017-02-20 177 views
0

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

我的代码:

<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> 

我竭力要解决这个问题,因为我不能在网上找到任何解决办法,我不能确定如何调试它。任何帮助将非常感激。

感谢

编辑:在镀铬的错误消息:

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) 

回答

0

看起来你必须允许跨域请求:

如果你运行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 
+0

如果它不工作,尝试通过谷歌更换gstatic – Antho

相关问题