[英]reCAPTCHA Permission denied to access property
當我單擊該框確認我不是機器人時,藍色微調器開始旋轉,但永不停止。 最終在瀏覽器控制台中出現錯誤“錯誤:拒絕訪問屬性的權限”,后跟一個(看似)隨機的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)
看來您必須允許跨域請求:
如果您運行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
<head> ... <META HTTP-EQUIV="Access-Control-Allow-Origin" CONTENT=" http://www.example.org "> ... </head>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.